Thursday, November 27, 2008

Using Flags to Enable a User Account

Uses the userAccountControl to enable a user account.

Const ADS_UF_ACCOUNTDISABLE = 2
 
Set objUser = GetObject _
  ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")
intUAC = objUser.Get("userAccountControl")
 
If intUAC AND ADS_UF_ACCOUNTDISABLE Then
  objUser.Put "userAccountControl", intUAC XOR ADS_UF_ACCOUNTDISABLE
  objUser.SetInfo
End If

This is a VB Script, this can be used by saving the file in .vbs file