Méthode IDirectorySearch::AbandonSearch (iads.h)

La méthode IDirectorySearch::AbandonSearch abandonne une recherche lancée par un appel antérieur à la méthode ExecuteSearch .

Syntaxe

HRESULT AbandonSearch(
  [in] ADS_SEARCH_HANDLE phSearchResult
);

Paramètres

[in] phSearchResult

Fournit un handle au contexte de recherche.

Valeur retournée

Cette méthode retourne les valeurs de retour standard, y compris S_OK si la première ligne est obtenue avec succès.

Pour les autres valeurs de retour, consultez Codes d’erreur ADSI.

Notes

IDirectorySearch::AbandonSearch peut être utilisé si les options Page_Size ou asynchrones peuvent être spécifiées via IDirectorySearch::SetSearchPreference avant l’exécution de la recherche.

Exemples

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 );

Configuration requise

   
Client minimal pris en charge Windows Vista
Serveur minimal pris en charge Windows Server 2008
Plateforme cible Windows
En-tête iads.h
DLL Activeds.dll; Adsldp.dll; Adsldpc.dll

Voir aussi

Codes d’erreur ADSI

IDirectorySearch

IDirectorySearch::ExecuteSearch

IDirectorySearch::SetSearchPreference