Skip to Content
Active Directory Cookbook
book

Active Directory Cookbook

by Robbie Allen
September 2003
Intermediate to advanced
624 pages
15h 49m
English
O'Reilly Media, Inc.
Content preview from Active Directory Cookbook

6.7. Copying a User

Problem

You want to copy an existing user account, which may be serving as a template, in order to create a new account.

Solution

Using a graphical user interface

  1. Open the Active Directory Users and Computers snap-in.

  2. In the left pane, browse to the parent container of the template user object.

  3. In the right pane, right-click on the user and select Copy.

  4. Enter the name information for the new user and click Next.

  5. Enter a password, check any options you want enabled, and click Next.

  6. Click Finish.

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Active Directory Administration Cookbook

Active Directory Administration Cookbook

Sander Berkouwer
Active Directory Cookbook, 3rd Edition

Active Directory Cookbook, 3rd Edition

Laura E. Hunter, Robbie Allen
Active Directory Cookbook, 4th Edition

Active Directory Cookbook, 4th Edition

Brian Svidergol, Robbie Allen

Publisher Resources

ISBN: 0596004648Supplemental ContentCatalog PageErrata