September 2003
Intermediate to advanced
624 pages
15h 49m
English
You want to copy an existing user account, which may be serving as a template, in order to create a new account.
Open the Active Directory Users and Computers snap-in.
In the left pane, browse to the parent container of the template
user object.
In the right pane, right-click on the user and select Copy.
Enter the name information for the new user and click Next.
Enter a password, check any options you want enabled, and click Next.
Click Finish.
' This code copies the attributes in the Attrs array from an
' existing object to a new one.
' ------ SCRIPT CONFIGURATION ------
arrAttrs = Array("department","co","title","l", "c", "st")
strParentDN = "<ParentContainer>" ' e.g. cn=Users,dc=rallencorp,dc=com
strTemplateUser = "<TemplateUserName>" ' e.g. template-user-sales
strNewUser = "<NewUserName>" ' e.g. jdoe
strPassword = "<Password>" ' ------ END CONFIGURATION --------- Const ADS_UF_NORMAL_ACCOUNT = 512 ' from ADS_USER_FLAG_ENUM Set objTemplate = GetObject("LDAP://cn=" & strTemplateUser & _ "," & strParentDN) Set objParent = GetObject("LDAP://" & strParentDN) Set objUser = objParent.Create("user", "cn=" & strNewUser) objUser.Put "sAMAccountName", strNewUser objUser.Put "userAccountControl", ADS_UF_NORMAL_ACCOUNT for each strAttr in arrAttrs objUser.Put strAttr, objTemplate.Get(strAttr) next objUser.SetInfo objUser.SetPassword(strPassword) objUser.AccountDisabled = FALSE objUser.SetInfo WScript.Echo "Successfully ...