After a default Exchange 2003/2007 installation, the Global Address List is displayed as GivenName, SirName. Most of our customers want to change this in SirName, GiveName, so that the users can search on the SirName instead of the GivenName.
With the following script you can change the displaynames of all userobjects in the Domain, or in an Organizational Unit.
The only thing you have to change is: ‘LDAP://OU=edir, DC=e2k7 ,DC=local’. Let’s say your domain is company.lan and the Organizational Unit where the userobject are placed is CompanyUsers, it would be:
“LDAP://OU=CompanyUsers, DC=company, DC=lan’
_______________________________________________________
On Error Resume Next
Set con = CreateObject(“ADODB.Connection”)
con.Provider = “ADsDSOObject”
con.Open
set command = CreateObject(“ADODB.Command”)
set command.ActiveConnection = con
command.CommandText = “SELECT adsPath, samAccountName,Sn, givenName, DisplayName, userAccountControl FROM ‘LDAP://OU=edir, DC=e2k7 ,DC=local’ WHERE objectClass = ‘user’ AND samAccountName <> ‘Administrator’ AND samAccountName <> ‘*$’ AND userAccountControl <> 514 ORDER BY samAccountName”
Set rs = command.Execute
While not rs.EOF
GebruikersNaam=rs.Fields(“adsPath”).Value
set oUser = GetObject(GebruikersNaam)
oUser.Displayname = rs.fields(“Sn”).value & CHR(44) &” ” & rs.fields(“givenName”).value
oUser.SetInfo
Set oUser = Nothing
rs.MoveNext
Wend
con.close
Set con = nothing
MSGBox “Klaar!”
_______________________________________________________