IDirectorySearch::GetColumn method (iads.h)
The IDirectorySearch::GetColumn method gets data from a named column of the search result.
Syntax
HRESULT GetColumn(
[in] ADS_SEARCH_HANDLE hSearchResult,
[in] LPWSTR szColumnName,
[out] PADS_SEARCH_COLUMN pSearchColumn
);
Parameters
[in] hSearchResult
Provides a handle to the search context.
[in] szColumnName
Provides the name of the column for which data is requested.
[out] pSearchColumn
Provides the address of a method-allocated ADS_SEARCH_COLUMN structure that contains the column from the current row of the search result.
Return value
This method returns the standard return values, as well as the following.
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 must free the memory by calling IDirectorySearch::FreeColumn.
The IDirectorySearch::GetColumn method tries to read the schema definition of the requested attribute so it can return the attribute values in the appropriate format in the ADSVALUE structures, contained in the ADS_SEARCH_COLUMN structure. However, GetColumn can succeed even when the schema definition is not available, in which case the dwADsType member of the ADS_SEARCH_COLUMN structure returns ADSTYPE_PROV_SPECIFIC and the value is returned in an ADS_PROV_SPECIFIC structure. When you process the results of a GetColumn call, you must verify dwADsType to ensure that the data was returned in the expected format.
Examples
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) )
{
switch (col.dwADsType)
{
case ADSTYPE_CASE_IGNORE_STRING:
printf("%S\n", col.pADsValues->CaseIgnoreString);
break;
case ADSTYPE_PROV_SPECIFIC:
printf("%S\n", col.pADsValues->ProviderSpecific.lpValue);
break;
default:
printf("Unexpected ADsType: %d\n", col.dwADsType);
break;
}
{
m_pSearch->FreeColumn( &col );
}
}
}
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 |