Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

IADsObjectOptions::GetOption method

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

Syntax


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 value

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 pvValue parameter. For more information, see ADSI Error Codes.

Examples

The following 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 code example shows how to determine if mutual authentication is used.


'   IsUsingMutualAuth()
'
'   Returns True if Mutual authentication is used or False otherwise.

Public Function IsUsingMutualAuth(ADsPath As String) As Boolean
    Const ADS_OPTION_MUTUAL_AUTH_STATUS = 4
    Const ISC_RET_MUTUAL_AUTH = 2
    
    IsUsingMutualAuth = False
    
    Dim oObjOptions As IADsObjectOptions
    
    Set oObjOptions = GetObject(ADsPath)
    AuthStatus = oObjOptions.GetOption(ADS_OPTION_MUTUAL_AUTH_STATUS)
    If AuthStatus And ISC_RET_MUTUAL_AUTH Then
        IsUsingMutualAuth = True
    End If
End Function


The following 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();

The following code example shows how to determine if mutual authentication is used.


/*

    IsUsingMutualAuth()

    Returns S_OK if mutual authentication is used, S_FALSE if mutual 
    authentication is not used or an error code if an error occurs.

*/

HRESULT IsUsingMutualAuth(LPCWSTR pwszADsPath)
{
    if(!pwszADsPath)
    {
        return E_INVALIDARG;
    }
    
    HRESULT hr;
    CComPtr<IADsObjectOptions> spObjectOptions;

    hr = ADsGetObject(pwszADsPath, IID_IADsObjectOptions, 
                     (LPVOID*)&spObjectOptions);
    if(FAILED(hr))
    {
        return hr;
    }

    CComVariant svar;
    hr = spObjectOptions->GetOption(ADS_OPTION_MUTUAL_AUTH_STATUS,
                                     &svar);
    if(FAILED(hr))
    {
        return hr;
    }

    if(VT_I4 == svar.vt)
    {
        if(ISC_RET_MUTUAL_AUTH & svar.lVal)
        {
            // Mutual authentication is set.
            return S_OK;
        }

        // Mutual authentication is not set.
        return S_FALSE;
    }

    // The data type was unexpected.
    return E_FAIL;
}

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2003

Header

Iads.h

DLL

Activeds.dll

IID

IID_IADsObjectoptions is defined as A1CD2DC6-EFFE-11CF-8ABC-00C04FD8D503

See also

ADS_OPTION_ENUM
ADSI Error Codes
IADsObjectOptions

 

 

Show:
© 2015 Microsoft