Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
For a computer in your organization to have full access to Active Directory resources, it must have a corresponding computer account in Active Directory. Computers that do not have accounts in Active Directory and do not belong to a domain have limited access to resources and cannot be managed by using Group Policy or software installation and maintenance.
Table 9.3 lists the Microsoft Windows operating systems and indicates whether a computer running a given operating system requires a computer account in Active Directory.
Table 9.3 Operating Systems and Computer Account Requirements
Operating System | Computer Account Required |
---|---|
Windows XP Home Edition | |
Windows XP Professional | ![]() |
Windows XP 64-Bit Edition | ![]() |
Windows 2000 Professional | ![]() |
Windows 2000 Server | ![]() |
Windows 2000 Advanced Server | ![]() |
Windows 2000 Datacenter Server | ![]() |
Windows NT Server 4.0 | ![]() |
Windows NT Server 4.0, Terminal Server Edition | ![]() |
Windows NT Server 4.0, Enterprise Edition | ![]() |
Windows NT Workstation 4.0 | ![]() |
Windows NT Server 3.51 | ![]() |
Windows NT Workstation 3.51 | ![]() |
Windows Millennium Edition | |
Windows 98 | |
Windows 95 | |
Windows 3.1 |
Computer accounts can be created programmatically by using ADSI (and, more specifically, by using the IADs interface). To create a large number of computer accounts in a single operation, you can write a script that reads relevant information (computer name, computer location, and so forth) from a text file or a database, and then creates an account for each new computer. Using this kind of script is much quicker than manually creating each computer account by using Active Directory Users and Computers.
Note
When you create a computer account, you need to specify only the common name and the Security Accounts Manager (SAM) account name; the other mandatory attributes are automatically created for you.
However, if you specify only those two items, the account will initially be disabled. For a computer account to be enabled, you must also set the appropriate flags in the userAccountControl attribute. The userAccountControl attribute determines a number of different account attributes, including whether an account is enabled or disabled and whether an account requires a password. By setting two flags (ADS_UF_PASSWD_NOTREQD and ADS_UF_WORKSTATION_TRUST_ACCOUNT), the account will be enabled upon creation.
For the purposes of this chapter, consider the userAccountControl attribute to be a control panel with a series of switches. These switches can be set to on or off. If a switch is set to on, the attribute controlled by that switch (the flag within the userAccountControl attribute) is also on. For example, if the ADS_UF_WORKSTATION_TRUST_ACCOUNT switch is on, that means that the account is a trusted workstation account. If the switch is off, the account is not a trusted workstation account. For a computer account to be enabled, both the ADS_UF_PASSWD_NOTREQD and ADS_UF_WORKSTATION_TRUST_ACCOUNT switches must be on.
Each flag within the userAccountControl attribute is assigned a value; for example, ADS_UF_PASSWD_NOTREQD is assigned the value &h0020 and ADS_UF_WORKSTATION_TRUST_ACCOUNT is assigned the value &h1000. These values correspond to the switches in the hypothetical control panel. When the userAccountControl attribute is assigned the value &h0020, it effectively flips the switch for ADS_UF_PASSWD_NOTREQD. Likewise, assigning the value &h1000 flips the switch for ADS_UF_WORKSTATION_TRUST_ACCOUNT.
If you are wondering how the userAccountControl attribute can be assigned multiple values, it is because the userAccountControl attribute contains multiple switches (flags).
For a more technical explanation of both the userAccountControl attribute and setting flags within that control, see "Active Directory Users" in this book.
Listing 9.2 contains a script that creates a computer account in Active Directory. To carry out this task, the script must perform the following steps:
These two constants are used to configure flags in the userAccountControl property and enable the new computer account. You can create a computer account merely by specifying a value for the sAMAccountName attribute. In that case, however, the account will be created but will not be enabled, and thus cannot be used immediately.
Listing 9.2 Creating a Computer Account in Active Directory
|
|
After the account has been created, the computer in question must still be joined to the domain. This can be done only by someone who has the right to join a computer to the domain and who has access rights to the newly created computer account. By default, only administrators have access to the computer account; consequently, only an administrator can join the computer to the domain.
![]() | « Previous | Next » |