Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
It is often necessary to locate all attributes that contain similar but not identical values so that these values can be modified. For example, you might need to locate all user accounts that start with the same network path in their user profile path, or user accounts with the same area code specified for their telephoneNumber attribute.
Listing 7.30 contains a script that finds all user accounts in the forest that contain a similar value for an attribute. To carry out this task, the script performs the following steps:
Line 8 specifies the search base by using the GC moniker to query the global catalog server in the Active Directory root domain, fabrikam.com, because the telephoneNumber and distinguishedName attributes are replicated to the global catalog.
Line 9 specifies the search filters for the query. The objectCategory filter limits the query to all user account types. The telephoneNumber filter uses the any operator to limit the query to telephoneNumber attribute values starting with 707.
Line 10 specifies the attributes of the objects to return, the distinguishedName and telephoneNumber attributes, and the scope of the search.
Listing 7.30 Searching for User Accounts That Contain a Similar Value in an Attribute
|
|
The example shown in Listing 7.30 uses a search filter that performs post-wildcard matching on an indexed attribute. In this example, post-wildcard matching means that all telephoneNumber attribute values that start with 707 are returned. Pre-wildcard matching, such as (telephoneNumber=*707-9794), and mid-wildcard matching, such as (telephoneNumber=425*9794), should not be performed against a potentially large result set. This is because the server performs significantly more processing to return such a result set than to return a result set from a post-wildcard match. If you must perform a pre- or mid-wildcard match, consider limiting the search to a smaller search base and search scope.
Send us your feedback | « Previous | Next » |