Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

IDirectorySearch::GetColumn method

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

Syntax


HRESULT GetColumn(
  [in]   ADS_SEARCH_HANDLE hSearchHandle,
  [in]   LPWSTR szColumnName,
  [out]  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 value

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

For other return values, see ADSI Error Codes.

Return codeDescription
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.

 

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

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Iads.h

DLL

Activeds.dll;
Adsldp.dll;
Adsldpc.dll

IID

IID_IDirectorySearch is defined as 109BA8EC-92F0-11D0-A790-00C04FD8D5A8

See also

IDirectorySearch
IDirectorySearch::FreeColumn
ADS_SEARCH_COLUMN
ADSI Error Codes

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.