Article ID: 325189 - View products that this article applies to.
This article was previously published under Q325189
This article has been archived. It is offered "as is" and will no longer be updated.
MSDN documentation about the IDirectorySearch::GetNextRow function is incomplete. The description of return value S_ADS_NOMORE_ROWS is false. This code does not mean "The current row is the last row and remains to be unchanged". Instead, the description should say "for now, current row is the last row", and if you want to know if this is really the last row, you have to call ADsGetLastError."
For each failed operation, ADSI sets an extended error code, which can be queried using ADsGetLastError. If this extended error is not handled by developer, a search operation may conclude prematurely before all rows have been processed. For additional information about the latest service pack for Microsoft Windows 2000, click the following article number to view the article in the Microsoft Knowledge Base:
(https://support.microsoft.com/kb/260910/EN-US/ )How to Obtain the Latest Windows 2000 Service Pack
When the IDirectorySearch::GetNextRow function returns S_ADS_NOMORE_ROWS, it may not have retrieved all the data from the server. In some cases, S_ADS_NOMORE_ROWS is returned by GetNextRow function when the server was unable to find an entry that matched the search criteria within a predefined two-minute time limit. This two-minute time limit is defined by means of an LDAP policy. For additional information about LDAP policies, click the article number below to view the article in the Microsoft Knowledge Base:
315071If the server exceeds the two-minute time limit, it returns an LDAP cookie in the response so that you can restart the search where it left off. Inefficient searches and heavily loaded systems can cause the server to exceed the time limit. When the server cannot find an efficient index to search, the server may have to apply the filter to every object in the directory, in which case it can run through many entries and not find a match within the two-minute time limit.
(https://support.microsoft.com/kb/315071/EN-US/ )HOW TO: View and Set LDAP Policies by Using Ntdsutil.exe
Therefore, when returning S_ADS_NOMORE_ROWS, ADSI also sets an extended error code, which can be queried using ADsGetLastError function. If ADsGetLastError returns ERROR_MORE_DATA, it means that the server has not completed the query and must call GetNextRow again.
The Platform SDK sample file, DsSrch, can be modified to handle this search method as shown in the following code sample:
For more information, visit the following MSDN Web sites:
Article ID: 325189 - Last Review: January 17, 2015 - Revision: 4.0