J
Joe Granto
I am working on a VB script that creates users. I have gone to the MS
site and looked at their sample code, and searched on the internet,
and have the script so that it works relatively well. However, I am
still unable to do one thing I would really like to do. I should
probably add that I am not all that fluent with VBScript...
When I open AD Users and Computers (ADUC), call up a user account,
there are many fields. The fields I am interested in, as labeled in
ADUC, are:
General Tab
Display name
Description
Account Tab
User logon name
The script listed below is able to add data all three fields. The
problem, however, is that the account created does not show up in ADUC
as listed in "Display name"; rather, it is listed as "User logon
name".
For example, say I create the following account:
Display name = Bar, Foo
Description = Test account
User logon name = Foo.Bar
The script runs without errors, and under ADUC, the account is
displayed with all the other accounts as "Foo.Bar" and not "Bar, Foo".
When I open the properties of the account, the "Display name" field
shows the account as "Bar, Foo" even though it is not displayed that
way.
My question: how can I get the account I create to be displayed in
ADUC with the "Display name" data instead of the "User logon name"
data?
Thanks for the help!
Here is the section of my script that makes the AD mods:
-------------------------
Set oOU = GetObject("LDAP://" & vOU)
Set oUser = oOU.Create("User", "cn=" & vUName)
oUser.Put "sAMAccountName", vUName
If Not(vDescription = "") then
oUser.PutEx ADS_PROPERTY_UPDATE, "description", Array(vDescription)
End If
oUser.Put "displayName", vDName
oUser.Put "userPrincipalName", VUName & "@dsmain.com"
oUser.SetInfo
'On Error resume next
Set oUser = GetObject("LDAP://cn=" & vUName & "," & vOU)
oUser.AccountDisabled = FALSE
oUser.SetPassword vPassword
oUser.SetInfo
Please replace the "NoSpam" with "MCI" in my email address in order to
reply.
site and looked at their sample code, and searched on the internet,
and have the script so that it works relatively well. However, I am
still unable to do one thing I would really like to do. I should
probably add that I am not all that fluent with VBScript...
When I open AD Users and Computers (ADUC), call up a user account,
there are many fields. The fields I am interested in, as labeled in
ADUC, are:
General Tab
Display name
Description
Account Tab
User logon name
The script listed below is able to add data all three fields. The
problem, however, is that the account created does not show up in ADUC
as listed in "Display name"; rather, it is listed as "User logon
name".
For example, say I create the following account:
Display name = Bar, Foo
Description = Test account
User logon name = Foo.Bar
The script runs without errors, and under ADUC, the account is
displayed with all the other accounts as "Foo.Bar" and not "Bar, Foo".
When I open the properties of the account, the "Display name" field
shows the account as "Bar, Foo" even though it is not displayed that
way.
My question: how can I get the account I create to be displayed in
ADUC with the "Display name" data instead of the "User logon name"
data?
Thanks for the help!
Here is the section of my script that makes the AD mods:
-------------------------
Set oOU = GetObject("LDAP://" & vOU)
Set oUser = oOU.Create("User", "cn=" & vUName)
oUser.Put "sAMAccountName", vUName
If Not(vDescription = "") then
oUser.PutEx ADS_PROPERTY_UPDATE, "description", Array(vDescription)
End If
oUser.Put "displayName", vDName
oUser.Put "userPrincipalName", VUName & "@dsmain.com"
oUser.SetInfo
'On Error resume next
Set oUser = GetObject("LDAP://cn=" & vUName & "," & vOU)
oUser.AccountDisabled = FALSE
oUser.SetPassword vPassword
oUser.SetInfo
Please replace the "NoSpam" with "MCI" in my email address in order to
reply.