Directory Services

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 SAT scores of a school district, you can query the top ten students with the highest SAT 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. This operation is shown in the following code example. A size limit value of zero indicates no size limit.

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 determined by the operating system version. For Windows 2000, the limit is 1000 objects. For Windows Server 2003 family operating systems, the limit is 1500 objects.