Platform SDK: Active Directory, ADSI, and Directory Services

IADsObjectOptions::GetOption

The IADsOptions::GetOption method retrieves a provider-specific option for manipulating a directory object.

HRESULT IADsObjectOptions::GetOption(
  DWORD dwOption,
  void *pValue)
);

Parameters

dwOption
[in] A constant that indicates a provider-specific option, as defined in the ADS_OPTION_ENUM enumeration.
pValue
[retval, out] A pointer to a setting of the option specified by dwOption. For example, if dwOption is set to be ADS_OPTION_PAGE_SIZE, pValue refers to the number of pages.

Return Values

The method supports the standard return values, including S_OK if the operation is successful, and E_ADS_BAD_PARAMETER if the user has supplied an invalid pValue parameter. For other return values, see ADSI Error Codes.

Example Code [Visual Basic]

The following Visual Basic® code example shows how to search for the host name of a server using the ADS_OPTION_SERVERNAME option, and determine the page size using the ADS_OPTION_PAGE_SIZE option.

Dim cont As IADsContainer
Dim opt As IADsObjectOptions
 
Set cont = GetObject("LDAP://OU=Sales,DC=Microsoft,DC=com")
Set opt = cont
srvName = opt.GetOption(ADS_OPTION_SERVERNAME)
MsgBox "We connecting to " & srvName
PageSize = opt.GetOption(ADS_OPTION_PAGE_SIZE)

Example Code [C++]

The following C++ code snippet searches for the host name of a server and determines the page size using the ADS_OPTION_SERVERNAME and ADS_OPTION_PAGE_SIZE options, respectively.

IADsContainer *pCont;
IADsObjectOptions *pOps;
LPWSTR adsPath = L"LDAP://OU=Sales,DC=Microsoft,DC=com";
HRESULT hr =S_OK;
hr = ADsGetObject(adsPath,IID_IADsContainer,(void**)&pCont);
if(FAILED(hr)) exit(hr);
 
hr = pCont->QueryInterface(IID_IADsObjectOptions,(void**)&pOps);
pCont->Release();
 
VARIANT var;
VariantInit(&var);
hr = pOps->GetOptions(ADS_OPTION_SERVERNAME,&var);
printf("Server name: %n", V_BSTR(&var));
VariantClear(&var); 
 
hr = pOps->GetOption(ADS_OPTION_PAGE_SIZE, &var);
printf("Page size : %d\n",V_I4(&var));
 
VariantClear(&var);
pOps->Release();

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

ADS_OPTION_ENUM, ADSI Error Codes, ADS_SECURITY_INFO_ENUM, IADsObjectOptions