Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
Sorting a large result set can be useful, particularly when you need to group similar values together in an easy-to-read list. Ideally, you should perform searches on indexed attributes because the server performs the sort operation while it is building the result set. Otherwise, the server must generate the entire result set before performing a sort operation. To instruct the server to perform a sort operation, set the Sort On property of the Command object to the attribute you want to sort. If multiple attributes are defined for the sort operation, separate each one with a comma.
Even though the physicalDeliveryOfficeName attribute that appears in Listing 7.32 is not in the global catalog, it is an indexed attribute. Therefore, the server can efficiently sort the result set.
An interesting caveat to searching the directory with referral chasing and sorting enabled is that each domain controller performs the search operation independently. Therefore, the result set is returned in separately sorted blocks. That is, the result set for the root domain will be sorted, and then the result set for each child domain will be sorted. Conversely, a search of the global catalog with sorting enabled returns a single sorted list to the client computer. To obtain a single sorted result set in this way, the attribute must be replicated to the global catalog.
Listing 7.32 contains a script that lists all user account types in a domain and the value of an attribute that is not contained in the global catalog. Sorting is enabled on an indexed attribute. To carry out this task, the script performs the following steps:
Listing 7.32 Sorting a Result Set from a Search of the Active Directory
|
|
Send us your feedback | « Previous | Next » |