Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
At times it might be necessary to search for multivalued attributes. For example, you might want a list of user accounts with URLs listed in the url multivalued attribute, or you might want to retrieve a list of direct reports listed in the directReports multivalued attribute for user accounts in a particular OU.
Multivalued attributes are not indexed and not located in the global catalog, so searches for this type of attribute should be limited in scope.
Listing 7.31 contains a script that finds all user accounts in an OU that contain values in a multivalued attribute. To carry out this task, the script performs the following steps:
Line 8 specifies the search base using the LDAP moniker to query a domain controller in the na.fabrikam.com domain because the otherTelephone attribute is not replicated to the global catalog. The search base has been intentionally limited to the Management OU because not only is the otherTelephone attribute not in the global catalog, but it is not an indexed attribute, either. Limiting the result set by specifying the Management OU as the search base avoids overburdening the domain controller with an intensive search request.
Line 9 specifies the objectCategory=person and otherTelephone=* search filters to limit the result set to all user account types that contain values for the otherTelephone attribute. This does not exclude the contact account type, which can contain a value for the otherTelephone attribute. User account types without a value for the otherTelephone attribute are not returned by the query because the * (ANY operator) means that the attribute must be present that is, it must contain a value.
Line 10 specifies the attributes of the objects to return, the cn and otherTelephone attributes, and the scope of the search. The search scope has been limited to onelevel so that only user accounts in the Management OU are searched and child OUs are not.
The end of line 16 shows that the Value property of the Fields collection is specified. The Value property is the default property and does not need to be specified when single-valued attributes are displayed. However, it is required for this script to display the values contained in the otherTelephone multivalued attribute.
Listing 7.31 Searching for User Accounts Containing a Particular Multivalued Attribute
|
|
Send us your feedback | « Previous | Next » |