Directory Services |
The IDirectorySearch::CloseSearchHandle method closes the handle to a search result and frees the associated memory.
HRESULT CloseSearchHandle( ADS_SEARCH_HANDLE hSearchHandle );
This method returns the standard return values, as well as the following:
For other return values, see ADSI Error Codes.
Return Code | Description |
---|---|
S_OK | The search result was closed. |
E_ADS_BAD_PARAMETER | The search handle is invalid. |
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.
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); }
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.
IDirectorySearch, IDirectorySearch::ExecuteSearch, ADSI Error Codes