IDirectorySearch::GetNextRow method

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

Syntax


HRESULT GetNextRow(
  [in] ADS_SEARCH_HANDLE hSearchHandle
);

Parameters

hSearchHandle [in]

Contains the search handle obtained by calling IDirectorySearch::ExecuteSearch.

Return value

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

For more information, see ADSI Error Codes.

S_OK

The next row was successfully obtained.

E_ADS_BAD_PARAMETER

The search handle is invalid.

S_ADS_NOMORE_ROWS

There are no more rows to retrieve or the search is waiting for a response. If ADsGetLastError returns ERROR_MORE_DATA, the search is waiting for a response and GetNextRow should be called again.

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.

The directory provider may limit the maximum number of rows available in a search. For example, on a Windows domain, the maximum number of rows that will be provided in an Active Directory search is 1000 rows. If the search results in more than the row limit, a paged search must be performed to obtain all rows in the search. For more information about paged searches, see Paging with IDirectorySearch.

Examples


hr = m_pSearch->ExecuteSearch(L"(objectCategory=contact)", pszAttr, dwCount, &hSearch);
if(SUCCEEDED(hr))
{
    while(SUCCEEDED(hr = m_pSearch->GetNextRow(hSearch)))
    {
        if(S_OK == hr)
        {
            // Get the data.
        }
        else if(S_ADS_NOMORE_ROWS == hr)
        {
            // Call ADsGetLastError to see if the search is waiting for a response.
            DWORD dwError = ERROR_SUCCESS;
            WCHAR szError[512];
            WCHAR szProvider[512];

            ADsGetLastError(&dwError, szError, 512, szProvider, 512);
            if(ERROR_MORE_DATA != dwError)
            {
                break;
            }
        }
        else
        {
            break;
        }
    }
    
    m_pSearch->CloseSearchHandle(hSearch);
}


Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008

Header

Iads.h

DLL

Activeds.dll;
Adsldp.dll;
Adsldpc.dll

IID

IID_IDirectorySearch is defined as 109BA8EC-92F0-11D0-A790-00C04FD8D5A8

See also

IDirectorySearch::GetFirstRow
IDirectorySearch::ExecuteSearch
ADsGetLastError
IDirectorySearch
ADSI Error Codes

 

 

Show: