You want to copy an existing user account, which may be serving as a template, in order to create a new account.
220.127.116.11 Using a graphical user interface
18.104.22.168 Using VBScript
' 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 created user"
Copying a user consists of copying the attributes that are common among a certain user base, which can include department, address, and perhaps even organizational information. ADUC actually uses attributes that are marked in the schema as "Copied when duplicating a user" to determine which attributes to copy. The VBScript solution just used a hardcoded set of attributes. If you are interested in finding the attributes that are configured in the schema to get copied, see Recipe 10.12.
22.214.171.124 Using a graphical user interface
In order to copy a user in ADUC, you have to browse to the user object. If you locate the user by using Find instead, the Copy option is not available when right-clicking a user in the search results window.
126.96.36.199 Using VBScript
ADSI has a CopyHere method, but it is available only for the NDS provider. It was not implemented for the LDAP provider and so copying a user via a single method is not supported.
6.7.4 See Also
Recipe 10.12 for finding the attributes that should be copied when duplicating a user