Size Limit with IDirectorySearch
To reduce the memory requirement or for other purposes, the client can focus on a small number of objects returned from the server and ignore the rest of the result set that are not of interest. To accomplish this, the client specifies the search size limit and other appropriate search criteria. For example, if the directory stores the test scores of a school district, you can query the top ten students with the highest test scores by specifying a size limit of ten (10) and a descending sort order.
The default for size limit is no limit. To set a size limit, set an ADS_SEARCHPREF_SIZE_LIMIT search option with an ADSTYPE_INTEGER value that contains the maximum size in the ADS_SEARCHPREF_INFO array passed to the IDirectorySearch::SetSearchPreference method.
The following code example shows how to set the size limit. A size limit value of zero indicates no size limit.
ADS_SEARCHPREF_INFO SearchPref; SearchPref.dwSearchPref = ADS_SEARCHPREF_SIZE_LIMIT; SearchPref.vValue.dwType = ADSTYPE_INTEGER; SearchPref.vValue.Integer = 1000;
For Active Directory, the size limit specifies the maximum number of objects to be returned by the search. Also for Active Directory, the maximum number of objects returned by a search is 1000 objects.