Directory Services

IADsObjectOptions::SetOption

The IADsOptions::SetOption method sets a provider-specific option for manipulating a directory object.

HRESULT SetOption( 
  LONG lnOption,
  VARIANT vValue
);

Parameters

lnOption
Indicates the provider-specific option to set. This parameter can be any value in the ADS_OPTION_ENUM enumeration, except ADS_OPTION_SERVERNAME.
vValue
Specifies the value to set for the option specified in the lnOption parameter.

Return Values

The method supports the standard return values, including S_OK for a successful operation and E_ADS_BAD_PARAMETER when 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 shows how to set options on a container object to enable paged search and referral chasing.

Const ADS_CHASE_REFERRALS_SUBORDINATE = &H20
Dim cont As IADsContainer
Dim chaseRef As Variant
Dim opt As IADsObjectOptions
 
Set cont = GetObject("LDAP://DC=Sales,DC=Fabrikam,DC=com")
Set opt = cont
 
' Set the referral and page size and then enumerate all the children objects.
chaseRef = ADS_CHASE_REFERRALS_SUBORDINATE
PageSize = 100
 
opt.SetOption ADS_OPTION_REFERRALS, chaseRef
opt.SetOption ADS_OPTION_PAGE_SIZE, PageSize
For Each child In cont
  Debug.Print child.Name
Next

Example Code [C++]

The following C++ code sets options on a container object to enable paged search and referral chasing.

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);
V_I4(&var)=ADS_CHASE_REFERRALS_SUBORDINATE;
V_VT(&var)=VT_I4;
hr = pOps->SetOption(ADS_OPTION_REFERRALS,var);
 
VariantClear(&var); 
V_I4(&var)=100;
V_VT(&var)=VT_I4;
hr = pOps->SetOption(ADS_OPTION_PAGE_SIZE, 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

ADSI Error Codes, IADsObjectOptions