Question : Setting Display Name and Full Name attributes in VBScript

I have a script that adds new users to Active Directory in the format

firstname.lastname

and sets the user's Display Name property to

"Firstname Lastname".

However, when I open Active Directory Users and Computers, the new users appear in the list with the dotted account name, instead of with the Display Name. I tried setting the Full Name property, but nothing changed.

Here is my code:

      recip = "CN=" & emailname

      ' get the container
      Set objContainer = GetObject(ldapOU)

' create a recipient
      Set objUser = objContainer.Create("User", recip)
      FullName = FirstName & " " & LastName
      objUser.Put "displayName", FullName
      objUser.Put "samAccountName", emailname
      objUser.Put "sn", LastName
      objUser.Put "givenName", FirstName
      objUser.Put "userPrincipalName", emailname & "@domain.com"


Thanks

Answer : Setting Display Name and Full Name attributes in VBScript

I changed my code so that the CN=FullName instead of CN=first.last, and the name displays correctly in Active Directory now.

recip = "CN=" & FullName
Set objUser = objContainer.Create("User", recip)

Do you foresee any problems with changing the common name (CN)?
Random Solutions  
 
programming4us programming4us