Directory Services |
The ADS_VLV structure contains metadata used to conduct virtual list view (VLV) searches. This structure serves two roles. First, it specifies the search preferences sent to the server. Second, it returns the VLV metadata from the server.
typedef struct ADS_VLV {
DWORD dwBeforeCount;
DWORD dwAfterCount;
DWORD dwOffset;
DWORD dwContentCount;
LPWSTR pszTarget;
DWORD dwContextIDLength;
LPBYTE lpContextID; } ADS_VLV;
To set the VLV by dwContentCount and dwOffset, you must also set the pszTarget to a null value. If pszTarget contains a non-null value, then it is used as the offset, otherwise, lOffset is used as the offset. It is recommended that you initialize the structure to zero.
The following code example shows how to retrieve the first 30 entries in a result set.
ADS_SEARCHPREF_INFO prefInfo[2]; ADS_VLV vlv; vlv.dwBeforeCount=0; vlv.dwAfterCount=30; vlv.dwOffset=1; vlv.dwContentCount=0; vlv.pszTarget = NULL; vlv.dwContextIDLength = 0; vlv.lpContextID = NULL; // VLV set preferences. prefInfo[0].dwSearchPref = ADS_SEARCHPREF_VLV; prefInfo[0].vValue.dwType = ADSTYPE_PROV_SPECIFIC; prefInfo[0].vValue.ProviderSpecific.dwLength = sizeof(ADS_VLV); prefInfo[0].vValue.ProviderSpecific.lpValue = (LPBYTE) &vlv; // Sort key set preferences. prefInfo[1].dwSearchPref = ADS_SEARCHPREF_SORT_ON; prefInfo[1].vValue.dwType = ADSTYPE_PROV_SPECIFIC; prefInfo[1].vValue.ProviderSpecific.dwLength = sizeof(ADS_SORTKEY); prefInfo[1].vValue.ProviderSpecific.lpValue = (LPBYTE) pSortKey; hr = m_pSearch->SetSearchPreference(prefInfo, 2);
The following code example shows how to retrieve the first 50 entries in a result set that start with the letters "Ha".
ADS_SEARCHPREF_INFO prefInfo[2]; ADS_VLV vlv; vlv.dwBeforeCount=0; vlv.dwAfterCount=50; vlv.pszTarget= L"Ha"; vlv.lpContextID = NULL; vlv.dwContextIDLength = 0; // For more information about how to set the preference, see the previous code example.
The following code example shows how to retrieve the first 100 entries at the 60% approximate target, assuming that the server previously returned dwContentCount as 4294.
Note vlvResp represents an ADS_VLV structure previously returned by the server.
ADS_SEARCHPREF_INFO prefInfo[2]; ADS_VLV vlv; vlv.dwBeforeCount=50; vlv.dwAfterCount=50; vlv.dwOffset=2577; vlv.dwContentCount=4294; vlv.pszTarget = NULL; vlv.dwContextIDLength = vlvResp.dwContextIDLength; vlv.lpContextID = vlvResp.lpContextID;
Client: Included in Windows XP.
Server: Included in Windows Server 2003.
Header: Declared in Iads.h.
How to Search Using VLV, ADS_SEARCHPREF_ENUM, IDirectorySearch