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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating AD Users Issue

Status
Not open for further replies.

TheLad

Technical User
Aug 3, 2001
3,846
GB
Guys

I have a script that creates users in AD. I am having issues whereby the newly created user is not assigned the proper display name. I have scripted it so that the displayname should be firstname & surname but the name (or Full Name) in ADUC always appears as the User ID.

The basics of my code are as follows (the strings are already pre-defined and work):

Code:
Set objUser = strUserContext.Create("User", "cn=" & strUserID)
objUser.Put "sAMAccountName", strUserID
objUser.Put "userPrincipalName", strUserID & "@" & strDomainForest
objUser.Put "givenName", strUserFirstName
objUser.Put "sn", strUserSurname
objUser.Put "displayName", strUserFirstName & " " & strUserSurname
objUser.Put "Description", strUserDescription
objUser.SetInfo

According to ADSI, it is the name field that changes however when I tried adding an objUser.Put "name" it didn't work. Please can anyone advise me where I am going wrong?

--------------------------------------
"Insert funny comment in here!"
--------------------------------------
 
I belive you need to do a SetInfo after setting the last name, then I belive you can modify that setting and do a SetInfo again to save that change.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top