Directory Services |
The IADsOptions::GetOption method gets a provider-specific option for a directory object.
HRESULT GetOption( LONG lnOption, VARIANT* pvValue );
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.
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)
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();
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.