IDirectorySearch::AbandonSearch method (iads.h)

The IDirectorySearch::AbandonSearch method abandons a search initiated by an earlier call to the ExecuteSearch method.

Syntax

HRESULT AbandonSearch(
  [in] ADS_SEARCH_HANDLE phSearchResult
);

Parameters

[in] phSearchResult

Provides a handle to the search context.

Return value

This method returns the standard return values, including S_OK if the first row is obtained successfully.

For other return values, see ADSI Error Codes.

Remarks

IDirectorySearch::AbandonSearch may be used if the Page_Size or Asynchronous options can be specified through IDirectorySearch::SetSearchPreference before the search is executed.

Examples

LPWSTR pszAttr[] = { L"ADsPath", L"Name", L"samAccountName" };
ADS_SEARCH_HANDLE hSearch;
DWORD dwCount= sizeof(pszAttr)/sizeof(LPWSTR);
////////////////////////////////////////////////////////////////////
// NOTE: Assume that m_pSearch is an IDirectorySearch pointer to the 
// object at the base of the search, and that the appropriate search 
// preferences have been set.
// For brevity, omit error handling.
////////////////////////////////////////////////////////////////////
 
// Search for all users with a last name that starts with h.
hr = m_pSearch->ExecuteSearch(L"(&(objectClass=user)(sn=h*))", pszAttr, dwCount, &hSearch );
while( m_pSearch->GetNextRow( hSearch) != S_ADS_NOMORE_ROWS )
{
    // Get the samAccountName
    hr = m_pSearch->GetColumn( hSearch, pszAttr[2], &col );
    if ( FAILED(hr) )
    {
        hr = m_pSearch->AbandonSearch( hSearch );
        hr = m_pSearch->CloseSearchHandle(hSearch);
        m_pSearch->Release();
        break;
    }
    if (col.dwADsType == ADSTYPE_CASE_IGNORE_STRING)
       printf("%S\n", col.pADsValues->CaseIgnoreString); 
   m_pSearch->FreeColumn( &col );
}
 
m_pSearch->CloseSearchHandle( hSearch );

Requirements

   
Minimum supported client Windows Vista
Minimum supported server Windows Server 2008
Target Platform Windows
Header iads.h
DLL Activeds.dll; Adsldp.dll; Adsldpc.dll

See also

ADSI Error Codes

IDirectorySearch

IDirectorySearch::ExecuteSearch

IDirectorySearch::SetSearchPreference