• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2712
  • Last Modified:

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
0
wcody
Asked:
wcody
  • 5
  • 2
1 Solution
 
Jay_Jay70Commented:
Hi wcody,

objUser.Put "displayName", FullName                  what does the FullName call on? i am guessing its the first.last
0
 
wcodyAuthor Commented:
Jay,

Thanks for your response. Actually, FullName is the first name followed by a space and then the last name. For example, it is in the form "John Doe".

FullName = FirstName & " " & LastName
0
 
Jay_Jay70Commented:
sorry mate i didnt even see that variable sitting right in front of me....... i am not huge on scripting but have been doing a lot of what you are doing of late, just trying to spot something in your code, but being a newbie at this i can't see it right off!  Its 1am here in Aus, let me look again in the morning for you :)

just a check, if you specify the full name manually in your display name field, does it work? you have declared that variable yes?
0
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 
wcodyAuthor Commented:
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)?
0
 
Jay_Jay70Commented:
nope, there shouldnt be any problems that i can see
0
 
Jay_Jay70Commented:
To be honest, i dont think i even helped at all so would be more than happy for a refund to wcody, thank you though, for the gesture

jay
0
 
Jay_Jay70Commented:
Thanks Annie,

Cheers wcody

Jay
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now