大网数据广告活动
域与目录服务

Adding an Auxiliary Class to an Object Instance

· 52CE 我爱测

The following code examples show how to use ADSI and LDAP to dynamically add an auxiliary class to an existing object instance.

The following code examples show how to use ADSI and LDAP to dynamically add an auxiliary class to an existing object instance. The examples assume that an auxiliary class named vehicle is defined in the Active Directory schema, and that the vehicle class has a vin attribute.

When you dynamically add an auxiliary class to an object instance, you must simultaneously specify values for any mandatory mustHave attributes in the class. The following examples show how to do this with the "vin" attribute, which is assumed to be mandatory.

The following C++ example binds to an object, and uses IADs.PutEx to append the auxiliary class to the list of classes in the object's objectClass property. Then the example uses IADs.Put to set the value of the vin attribute. Finally, it calls IADs.SetInfo to commit the changes to the directory.

LPWSTR pszAuxClass[]={L"vehicle"};
LPWSTR pszVIN[]={L"df897dsfsa-0"};
VARIANT var;

VariantInit(&var);

ADsOpenObject(L"cn=johnd,cn=users,dc=fabrikam,dc=com", 
    NULL, 
    NULL, 
    ADS_SECURE_AUTHENTICATION, 
    IID_IADs,  
    (VOID**)&pIADs);

ADsBuildVarArrayStr(pszAuxClass, 1, &var);
pIADs->PutEx(ADS_PROPERTY_APPEND, CComBSTR("objectClass"), var);
ADsBuildVarArrayStr( pszVIN, 1, &var);
pIADs->Put(CComBSTR("vin"), var);
pIADs->SetInfo();

if(pIADs)
    pIADs->Release();

VariantClear(&var);

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。