Bartosz Kowalski wrote:
>
> Is it possible to create user with cn=LasName, FirstName ??
> You can do it (by default) using AD Users management on W2K3 Server.
> How can I do it by VBscript?
Commas embedded in the Common Name must be escaped with the backslash escape
character. In brief:
========
strFirstName = InputBox("Enter new user first name")
strLastName = InputBox("Enter new user last name")
' Hard coded parent container.
strParent = GetObject("LDAP://ou=Sales,ou=West,dc=MyDomain,dc=com")
' Create new user object in the parent container.
' Note that the comma is escaped.
Set objUser = objParent.Create("user", "cn=" & strLastName & "\, " &
strFirst Name)
' Assign "pre-Windows 2000 logon name" to be first initial and last name.
' This value must be unique in the domain.
objUser.sAMAccountName = Left(strFirstName, 1) & strLastName
' Make user account enabled.
objUser.AccountDisabled = False
' Save new user object in AD
objUser.SetInfo
' Assign password.
objUser.SetPassword = "xyz312"
--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab -
http://www.rlmueller.net
--