Saturday, July 18, 2009

Scripts to manage Active Directory Users

Recently i worked on a requirement to manage AD from our app, and thought of sharing/posting few details


1. Simple User Authentication
Get LDAP object (oDSObj) and bind to an ADSI object using credentials as shown below
oDSObj.OpenDSObject("LDAP://" & _
StrNamingContext, "Domain\username", _
"password", ADS_SECURE_AUTHENTICATION)

if this throws error, credentials are invalid.

2. Change Password, Reset Password

objUser.ChangePassword OldPword,NewPword
objUser.SetPassword "gU1d0*!"

3. Unlock Account

objUser.put "lockoutTime",0