Platform SDK: Active Directory, ADSI, and Directory Services

IDirectorySearch::GetNextRow

The IDirectorySearch::GetNextRow method gets the next row of the search result. If IDirectorySearch::GetFirstRow is never called before, the IDirectorySearch::GetNextRow will issue a new search beginning from the first row. Otherwise, this method will advance to the next row.

HRESULT GetNextRow(
  ADS_SEARCH_HANDLE hSearchHandle  
);

Parameters

hSearchHandle
[in] Provides a handle to the search context.

Return Values

This method returns the standard return values, as well as the following:

S_OK
The next row was successfully obtained.
E_ADS_BAD_PARAMETER
The search handle is invalid.
S_ADS_NOMORE_ROWS
The current row is the last row and remains to be unchanged.

For other return values, see ADSI Error Codes.

Remarks

When the ADS_SEARCHPREF_CACHE_RESULTS flag is not set, only forward scrolling is permitted, because the client might not cache all the query results.

Example Code [C++]

hr = m_pSearch->ExecuteSearch(L"(objectCategory=contact)", pszAttr, dwCount, &hSearch );
if ( SUCCEEDED(hr) )
{
   while(  m_pSearch->GetNextRow(hSearch)  != S_ADS_NOMORE_ROWS )
   {
      /* Get the data */
   }
   m_pSearch->CloseSearchHandle(hSearch);
}

Requirements

  Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with DSClient).
  Windows 95/98: Requires Windows 95 or later (with DSClient).
  Header: Declared in Iads.h.

See Also

IDirectorySearch, IDirectorySearch::GetFirstRow, ADSI Error Codes