Platform SDK: Active Directory, ADSI, and Directory Services

IDirectorySearch::GetColumn

The IDirectorySearch::GetColumn method gets data from a named column of the search result.

HRESULT GetColumn(
  ADS_SEARCH_HANDLE hSearchHandle,  
  LPWSTR szColumnName,              
  PADS_SEARCH_COLUMN pSearchColumn  
);

Parameters

hSearchHandle
[in] Provides a handle to the search context.
szColumnName
[in] Provides the name of the column for which data is requested.
pSearchColumn
[out] Provides the address of a method-allocated ADS_SEARCH_COLUMN structure that contains the column from the current row of the search result.

Return Values

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

S_OK
The column was obtained successfully.
E_ADS_BAD_PARAMETER
The search handle or the column is invalid.
E_ADS_COLUMN_NOT_SET
No attributes and values can be found for the column.

For other return values, see ADSI Error Codes.

Remarks

The method allocates the memory for the ADS_SEARCH_COLUMN structure to hold the data of the column. But the caller is responsible for freeing the memory by calling IDirectorySearch::FreeColumn.

Example Code [C++]

ADS_SEARCH_COLUMN col;
/*.. Omit the set preference and execute*/
while( m_pSearch->GetNextRow( hSearch) != S_ADS_NOMORE_ROWS )
{
   // Get the Name and display it in the list.
   hr = m_pSearch->GetColumn( hSearch, pszAttr[0], &col );
   if ( SUCCEEDED(hr) )
   {
       printf("%S\n", col.pADsValues->CaseIgnoreString);
       m_pSearch->FreeColumn( &col );
   }
}
m_pSearch->CloseSearchHandle( hSearch );

Requirements

  Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with DSClient).
  Windows 95/98: Requires Windows 95 or later (with DSClient).
  Header: Declared in Iads.h.

See Also

IDirectorySearch, IDirectorySearch::FreeColumn, ADS_SEARCH_COLUMN, ADSI Error Codes