[ Team LiB ] |
Recipe 8.1 Creating a Computer8.1.1 ProblemYou want to create a computer account. 8.1.2 Solution8.1.2.1 Using a graphical user interface
8.1.2.2 Using a command-line interface> dsadd computer "<ComputerDN>" -desc "<Description>" 8.1.2.3 Using VBScript' This code creates a computer object. ' ------ SCRIPT CONFIGURATION ------ strBase = "<ParentComputerDN>" ' e.g. cn=Computers,dc=rallencorp,dc=com strComp = "<ComputerName>" ' e.g. joe-xp strDescr = "<Description>" ' e.g. Joe's Windows XP workstation ' ------ END CONFIGURATION --------- ' ADS_USER_FLAG_ENUM Const ADS_UF_WORKSTATION_TRUST_ACCOUNT = &h1000 set objCont = GetObject("LDAP://" & strBase) set objComp = objCont.Create("computer", "cn=" & strComp) objComp.Put "sAMAccountName", strComp & "$" objComp.Put "description", strDesc objComp.Put "userAccountControl", ADS_UF_WORKSTATION_TRUST_ACCOUNT objComp.SetInfo Wscript.Echo "Computer account for " & strComp & " created" 8.1.3 DiscussionCreating a computer object in Active Directory is not much different from creating a user object. I set the description attribute in the CLI and API solutions, but it is not a mandatory attribute. The only mandatory attribute is sAMAccountName which should be set to the name of the computer with $ appended. Also note that these solutions simply create a computer object. This does not mean any user can join a computer to the domain with that computer account. For more information creating a computer object and allowing a specific user or group to join the computer to the domain, see Recipe 8.2. 8.1.4 See AlsoRecipe 8.2 for creating a computer for a user, MS KB 222525 (Automating the Creation of Computer Accounts), MS KB 283771 (HOW TO: Pre-stage Windows 2000 Computers in Active Directory), MS KB 315273 (Automating the Creation of Computer Accounts), MS KB 320187 (HOW TO: Manage Computer Accounts in Active Directory in Windows 2000), and MSDN: ADS_USER_FLAG_ENUM |
[ Team LiB ] |