Directory Services

IDirectorySearch::AbandonSearch

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

HRESULT AbandonSearch( 
  ADS_SEARCH_HANDLE hSearchHandle
);

Parameters

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

Return Values

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.

Example Code [C++]

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

Client: Included in Windows XP and Windows 2000 Professional.
Server: Included in Windows Server 2003 and Windows 2000 Server.
Redistributable: Requires Active Directory Client Extension on Windows NT 4.0 SP6a and Windows 95/98/Me.
Header: Declared in Iads.h.

See Also

IDirectorySearch, IDirectorySearch::ExecuteSearch, IDirectorySearch::SetSearchPreference, ADSI Error Codes