Creating a Computer

Creating a Computer


You want to create a computer account.


Using a graphical user interface
  1. Open the ADUC snap-in.

  2. If you need to change domains, right-click on Active Directory Users and Computers in the left pane, select "Connect to Domain," enter the domain name, and click OK.

  3. In the left pane, browse to the parent container for the computer, right-click on it, and select New Computer.

  4. Enter the name of the computer. If necessary, place a checkmark next to "Assign this computer as a pre-Windows 2000 computer" or "Assign this computer as a backup domain controller." Click Next to continue.

  5. If you will be using this computer account as part of an RIS deployment, place a checkmark next to "This is a managed computer" and enter the GUID that it should use, and then click Next. Otherwise, just click Next to continue.

  6. Click Finish.

Using a command-line interface

You can create a computer object using either the built-in DSAdd utility or AdMod. To create an account using DSAdd, use the following syntax:

	> dsadd computer "<ComputerDN>" -desc "<Description>"

To create a computer account using AdMod, enter the following:

	> admod -b "<ComputerDN>" objectclass::computer
	  sAMAccountName::<ComputerName>$ userAccountControl::4096
	  description::"<Description>" -add

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 ---------


	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
	Wscript.Echo "Computer account for " & strComp & " created"


Creating a computer object in Active Directory is not much different from creating a user object. We 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 on creating a computer object and allowing a specific user or group to join the computer to the domain, see Recipe 8.2.

See Also

Recipe 8.2 for creating a computer for a user, MS KB 222525 (Automating the Creation of Computer Accounts), MS KB 283771 (How to Prestage 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

 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows