Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbscript add user to AD issue

Status
Not open for further replies.

dknecht

IS-IT--Management
Oct 12, 2011
4
US
I am trying to use the below script to make a user in AD:

username = "username"
Firstname = "FirstName"
lastname = "lastname"
description = "description"

Set objOU = GetObject("LDAP://OU=TheOU,dc=MyDC,dc=com")
Set objUser = objOU.Create("User", "cn="&username)
'initial account creation
objUser.Put "sAMAccountName", username
ObjUser.Put "SN", lastname
ObjUser.Put "description", description
objUser.Put "givenName", Firstname
objUser.SetInfo

The user gets created however the Account > User logon name is blank. Any idea what I am missing?
 
I think you need to populate both the sAMAccountName field and the userPrincipalName field
 
Excellent thank you! I knew I was missing something and that was it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top