IDirectorySearch::CloseSearchHandle method (iads.h)

The IDirectorySearch::CloseSearchHandle method closes the handle to a search result and frees the associated memory.

Syntax

HRESULT CloseSearchHandle(
  [in] ADS_SEARCH_HANDLE hSearchResult
);

Parameters

[in] hSearchResult

Provides a handle to the search result to be closed.

Return value

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

For other return values, see ADSI Error Codes.

Remarks

The process that implements the IDirectorySearch::CloseSearchHandle method must also be responsible for freeing all memory allocated by the IDirectorySearch::ExecuteSearch method, including the search result and the search result handle.

The caller may call this method only once for each opened search handle and must use the IDirectorySearch::ExecuteSearch method to obtain a new search handle after issuing IDirectorySearch::CloseSearchHandle.

Examples

ADS_SEARCH_HANDLE hSearch;
HRESULT hr;
hr = m_pSearch->ExecuteSearch(L"(&(objectCategory=user)(l=Redmond))", pszAttr, dwCount, &hSearch );
if ( SUCCEEDED(hr) )
{
   // Omit getting the data
   m_pSearch->CloseSearchHandle(hSearch);
}

Requirements

Requirement Value
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