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:
Sample C code for virtual list view:

And the same application using LDAP vlv:

Here's a code snippet that lets you query a server for metadata, including estimates of list size.

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



Find more PRO+ content and other member only offers, here.



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:









  • VDI assessment guide

    Wait! Don't implement VDI technology until you know your goals and needs. A VDI assessment should consider the benefits of a VDI ...

  • Guide to calculating ROI from VDI

    Calculating ROI from VDI requires a solid VDI cost analysis. Consider ROI calculation models, storage costs and more to determine...

  • Keep the cost of VDI storage under control

    Layering, persona management tools and flash arrays help keep virtual desktop users happy and VDI storage costs down.