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

User account missing First and Last name.

Status
Not open for further replies.

joltmon

IS-IT--Management
Jun 15, 2006
4
US
Our Helpdesk created several hundred user accounts with just a Display name and no First or Last name. I know just enough about VBScript to locate a script on the internet, make minor modification to suit my need and then run them, but I have not located a script to do what I need.

I need to read through our Active Directory tree, locate each user account, check to see of First and/or Last name is blank and then populate those fields with the information from Display name. Luckily, our Helpdesk filled in the Display field with LastName comma FirstName, so that I can split the Display name at the comma.

Can anyone get me started or pointed in the right direction?
 
I have just started using VBscripting to do alot a auditing on AD and found using LDAP searches time saving and very powerful.
One site I started on was:
but if you query 'VBscript & LDAP' on google you should get lots of info.
Also this is an awsome document:
At the bottom of the PDF it maps out all the LDAP objects. Or you can use ADSI edit and cycle through a user's properties to see the Object, Syntax and current value.

Below is a quick example of a query I did to find all the users which have their exchange mailboxes hidden. Just replace you Domain name on the first 'dc=' and on the second 'dc=' either .com or local which every way yours is set up.

Set oConfig = GetObject("LDAP://dc=YOURDOMAINNAME, dc=EITHER.COMorLOCAL")
Set oConn = CreateObject("ADODB.Connection")
oConn.Provider = "ADSDSOObject"
oConn.Open ""

strQuery = "<" & oConfig.adspath & ">;(&(objectCategory=person)(objectClass=User)(msExchPoliciesExcluded=*));name;subtree"
Set oRS = oConn.Execute(strQuery)
While Not oRS.EOF
user = oRS.Fields("name")
oRS.MoveNext
Wend
 
Thanks for your response. I’ll take a look at your answer and try to make heads or tails out it.

 
In the example runing a Query the only thing you need to be concerned about is the 'msExchPoliciesExcluded=*' which is searching that value which is the Check box in Exchange Advance tab for 'Hide From Exchange Address List' for a value. You would be searching for the object givenName (first name) and I think sn (last name) equals either null or <not set>. The part after where it says name '(msExchPoliciesExcluded=*));name;' Add any values between the semicolons that you want returned. I have only name being returned.
I haven't done any updating of the AD with this, but I think the hardest part is making the connection, once your connected you can update the fields as if it were a database.

Good Luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top