Directory Services

Getting the Server VLV Response

Two types of data are returned by the server for VLV searches: first, the return set of list entries, which are the directory objects and attributes retrieved by the VLV search, and second, metadata about the search, such as the approximate number of entries in the return set, the context ID, and an approximation of the offset value. List entries retrieved by the search are returned by the IDirectorySearch::GetNextRow method. VLV search metadata responses are retrieved by a call to the IDirectorySearch::GetColumn method.

To retrieve the VLV metadata

  1. Call either the IDirectorySearch::GetFirstRow or IDirectorySearch::GetNextRow method to retrieve at least one search result.
  2. Pass the ADS_VLV_RESPONSE value for the szColumnName parameter to the IDirectorySearch::GetColumn method.
  3. The IDirectorySearch::GetColumn method will return the VLV metadata as a column that contains an ADSVALUE structure of type ADSTYPE_PROV_SPECIFIC. The ProviderSpecific member of the ADSVALUE structure is an ADS_PROV_SPECIFIC. The lpValue member of the ADS_PROV_SPECIFIC structure is a pointer to the ADS_VLV structure that contains the metadata.

The following code example shows how to retrieve VLV results.

#include <iads.h>

ADS_VLV  vlv;

// Perform the SetSearchPreference.
// . . . 
// Perform the ExecuteSearch.
// . . . 
// Perform GetNextRow.

hr = pDSSearch->GetColumn( hSearch, ADS_VLV_RESPONSE, &col );
vlv =  *((PADS_VLV) col.pADsValue.ProviderSpecific.lpValue);
// Perform another operation.
hr = pDSSearch->FreeColumn( &col);