Directory Services

IADsObjectOptions::GetOption

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

HRESULT GetOption( 
  LONG lnOption,
  VARIANT* pvValue
);

Parameters

lnOption
Indicates the provider-specific option to get. This parameter can be any value in the ADS_OPTION_ENUM enumeration.
pvValue
Pointer to a VARIANT variable that receives the current value for the option specified in the lnOption parameter.

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 more information about 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=Fabrikam,DC=com")
Set opt = cont
srvName = opt.GetOption(ADS_OPTION_SERVERNAME)
MsgBox "Connecting to " & srvName
PageSize = opt.GetOption(ADS_OPTION_PAGE_SIZE)

Example Code [C++]

The following C++ code example 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=Fabrikam,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

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.

See Also

ADS_OPTION_ENUM, ADSI Error Codes, IADsObjectOptions