Export (0) Print
Expand All

IDirectorySearch::GetFirstRow method

The GetFirstRow method gets the first row of a search result. This method will issue or reissue a new search, even if this method has been called before.

Syntax


HRESULT GetFirstRow(
  [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.

Return codeDescription
S_OK

The first row was successfully obtained.

E_ADS_BAD_PARAMETER

The search handle is invalid.

S_ADS_NOMORE_ROWS

No rows can be found.

 

Remarks

When the ADS_SEARCHPREF_CACHE_RESULTS flag is not set, that is, FALSE, only forward scrolling is permitted, because the client might not cache all the query results. Calling GetFirstRow more than once from the same row requires some back-scrolling and could result in erroneous outcomes for a paged or an asynchronous search initiated through OLE DB when the results are not guaranteed to remain in the cache.

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 [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

Iads.h

DLL

Activeds.dll;
Adsldp.dll;
Adsldpc.dll

IID

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

See also

IDirectorySearch::ExecuteSearch
IDirectorySearch
ADSI Error Codes

 

 

Show:
© 2014 Microsoft