Q. Is there a script I can use to add a new Active Directory (AD) user via an LDAP connection?

John Savill

December 13, 2007

1 Min Read
ITPro Today logo in a gray background | ITPro Today

A. Yes there is. The script below creates a new user (“Bob Bobbington”) through an LDAP connection and adds the user to the “Users” container.

Set objOU = GetObject("LDAP://CN=Users,DC=savilltech,DC=net")
  Set objUser = objOU.Create("User", "cn=Bob Bobbington")
  objUser.Put "sAMAccountName", "Bob"
  objUser.Put "displayName", "Bob Bobbington"
  objUser.Put "name", "Bob Bobbington"
  objUser.Put "givenName", "Bob"
  objUser.Put "sn", "Bob"
  objUser.Put "department", "IT"
  objUser.Put "mail", "[email protected]"
  objUser.SetInfo
  objUser.AccountDisabled = false
  objUser.put "userPassword", "Pa55word"
  objUser.SetInfo

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like