Retrieving partial Active Directory lists

Using Virtual List View in Windows XP, admins can generate Active Directory complex searches.

Windows XP has a new active directory search feature Microsoft calls Virtual List View. You can use it to quickly retrieve sections of large lists without designing complicated searches.

Let's say you've got a huge address book in your AD forest and you want to let users browse it like they would browse a regular phone book. You could design the application with a thumb index metaphor and construct a search query based on the first letter or two of the last name. But what if you want to use a different metaphor, one that serves up some arbitrary section of the list, say the middle third or "Johnson +/- 1000 listings" ? XP supports such browsing using a technique Microsoft calls Virtual List Views.

There are two different values you can set to specify the first entry returned in a VLV search. The easiest to explain is lpszTarget, which you set to a string to be matched. For example, set it to "Johnson" , and you get a set of search rows that begin with the first entry of "Johnson" .

You can also specify the offset for the beginning of the result, but specifying the offset is tricky because you're dealing with a dynamic list. The server always treats an offset specification as a ratio. For example, let's say you think the address book contains 100,000 entries and you want to start at the middle. You can set lOffset to 50,000 and IContentCount to 100,000. The server takes that request and performs its own estimate of the size of the list, and may come up with an answer of 110,000. It will convert your offset estimate to 55,000, perform the search and return the result. The key thing to remember here is that offset specification is not precise, and you need to structure your code to tolerate the imprecision.

For more detail on the LDAP control and the ADSI wrapper that performs the search, see: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netdir/ad/how_to_search_using_vlv.asp
Sample C code for virtual list view: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netdir/ad/example_code_for_using_a_vlv_search.asp

And the same application using LDAP vlv: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netdir/ldap/example_code_for_using_ldap_vlv.asp

Here's a code snippet that lets you query a server for metadata, including estimates of list size. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netdir/adsi/getting_the_server_vlv_response.asp


Kevin Sharp is a registered professional engineer, writer, and yoga teacher living in Tucson, Arizona, and gains his expertise from a variety of professional activities.


This was first published in February 2002

Dig deeper on Microsoft Active Directory Design and Administration

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchServerVirtualization

SearchCloudComputing

SearchExchange

SearchSQLServer

SearchWinIT

SearchEnterpriseDesktop

SearchVirtualDesktop

Close