Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
Using the PutEx method with the clear control code (ADS_PROPERTY_CLEAR) applies to both single-valued and multivalued attributes. This control code deletes all existing entries. It is important for single-valued attributes because the Put method cannot completely clear an attribute. For example, you cannot specify NULL or "" for an attribute s value when calling Put. In addition, while the following code will work to update the telephoneNumber attribute, the telephoneNumber attribute is not empty. Instead, it contains a single space:
objUser.Put
"telephoneNumber
",
""
To Active Directory, this means that the user actually has a phone number, regardless of whether it is valid phone number. If you search Active Directory for all users without a phone number (that is, all users for whom the telephoneNumber attribute is null), this user will not be included in the returned data.
Therefore, PutEx is the only method capable of completely clearing one or more entries from an attribute.
Listing 7.16 contains a script that demonstrates how to remove an entry in a single-valued attribute and all entries in a multivalued attribute. To carry out this task, the script performs the following steps:
This control code removes entries from single-valued and multivalued attributes.
If no entry is assigned to the attribute, PutEx simply ignores the remove operation.
If no entries are assigned to the attribute, PutEx simply ignores the remove operation.
Listing 7.16 Removing Entries in Selected Single-valued and Multivalued Attributes
|
|
Send us your feedback | « Previous | Next » |