Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
Using scripts to configure user accounts is a good way to ensure a consistent attribute format and uniform attribute content among user accounts. For example, the script can dictate whether the displayName attribute should contain each user s givenName, initial, and sn in that order (for example, Ken E. Myer) or, alternatively, the sn, a comma, and the givenName (for example, Myer, Ken). Even if you make a mistake when configuring user account attributes with scripts, the mistake is uniform and likely to be easier to fix than the variety of mistakes common to manual entry.
The methods for writing single-valued and multivalued attributes are different. Use the Put method of IADs to assign single-valued entries, and use the PutEx method with the ADS_PROPERTY_UPDATE control code to write multivalued entries.
Listing 7.13 contains a script that writes values to the attributes appearing on the General properties page. Any existing entries are replaced with new entries specified in the script. To carry out this task, the script performs the following steps:
This control code replaces any existing entries in a multivalued attribute.
The Put method uses the attribute s lDAPDisplayName to identify the target attribute.
Because ADS_PROPERTY_UPDATE is specified when PutEx is called, any existing entries are replaced in the local property cache.
Listing 7.13 Writing Values to Attributes
|
|
You can use the Put method to write values to single-valued or multivalued attributes. As shown in Listing 7.13, there is no need to retrieve existing entries from attributes to assign new entries. This method replaces any existing entries. Therefore, if you need to log the values stored in existing attributes, retrieve the current entries using the Get method and store the values in a log file prior to using the Put method.
To confirm that an entry has been assigned, use the GetInfo (or GetInfoEx) method to retrieve the assigned entry or entries from Active Directory.
Send us your feedback | « Previous | Next » |