Platform SDK: Active Directory, ADSI, and Directory Services |
The IADsOptions::GetOption method retrieves a provider-specific option for manipulating a directory object.
HRESULT IADsObjectOptions::GetOption( DWORD dwOption, void *pValue) );
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.
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)
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();
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.
ADS_OPTION_ENUM, ADSI Error Codes, ADS_SECURITY_INFO_ENUM, IADsObjectOptions