我要在我公司的活动目录上添加一个属性!
我在msdn online上找到了微软给出的代码CreateAttribute()函数
但我在调用该函数后用IADs::SetInfo()提交新建立的属性时,出现了一个
“命名冲突的”错误,我真不知道怎样冲突
我的代码
IADs* pAds=NULL;
/* HRESULT hr = ADsGetObject(L"LDAP://schema",
  IID_IADs,
  (void**)&pAds);
*/
// Bind to the abstract schema.
IADsContainer *pAbsSchema = NULL;
HRESULT hr = ADsGetObject(L"LDAP://schema",
  IID_IADsContainer,
  (void**)&pAbsSchema); hr = ADsOpenObject(L"LDAP://schema",L"administrator",L"",
            ADS_SECURE_AUTHENTICATION,
IID_IADsContainer, (void**)&pAbsSchema);    hr=CreateAttribute(pAbsSchema,L"PaUserInfo",
               L"PaUserInfo",L"1.2.840.113556.1.4.1001",
   NULL,L"2.5.5.10",4,NULL,0,
   L"PaUserInfo",true,
   false,false,0,0,0,L"PaUserInfo",&pAds);
//提交到LDAP服务器
hr=pAds->SetInfo();//这里有错误

解决方案 »

  1.   

    我要在我公司的活动目录上添加一个属性!
    我在msdn online上找到了微软给出的代码CreateAttribute()函数
    但我在调用该函数后用IADs::SetInfo()提交新建立的属性时,出现了一个
    “命名冲突的”错误,我真不知道怎样冲突
    我的代码
    IADs* pAds=NULL;
    /* HRESULT hr = ADsGetObject(L"LDAP://schema",
      IID_IADs,
      (void**)&pAds);
    */
    // Bind to the abstract schema.
    IADsContainer *pAbsSchema = NULL;
    HRESULT hr = ADsGetObject(L"LDAP://schema",
      IID_IADsContainer,
      (void**)&pAbsSchema);/* hr = ADsOpenObject(L"LDAP://schema",L"administrator",L"",
                ADS_SECURE_AUTHENTICATION,
    IID_IADsContainer, (void**)&pAbsSchema);
    */    hr=CreateAttribute(pAbsSchema,L"PaUserInfo",
                   L"PaUserInfo",L"1.2.840.113556.1.4.1001",
       NULL,L"2.5.5.10",4,NULL,0,
       L"PaUserInfo",true,
       false,false,0,0,0,L"PaUserInfo",&pAds);
    //提交到LDAP服务器
    hr=pAds->SetInfo();//这里有错误