Directory Services

Result Caching with IDirectorySearch

The ADS_SEARCHPREF_CACHE_RESULTS preference caches the result set on the client. Result caching enables an application to retain a retrieved result set and go through the retrieved rows again. It also enables cursor support where the IDirectorySearch::GetNextRow and IDirectorySearch::GetPreviousRow methods can be used to move up and down the result set.

By default, result caching is disabled. Result caching should be enabled if any of the following are true:

Result caching increases the memory requirements on the client, so result caching should be disabled if this is a concern.

To enable result caching, set an ADS_SEARCHPREF_CACHE_RESULTS search option with an ADSTYPE_BOOLEAN value of TRUE in the ADS_SEARCHPREF_INFO array passed to the IDirectorySearch::SetSearchPreference method. This operation is shown in the following code example.

SearchPref.vValue.dwType = ADSTYPE_BOOLEAN;
SearchPref.vValue.Boolean = TRUE;