[Date Prev][Date Next] [Chronological] [Thread] [Top]

RE: Add an Entry with ADSI in C++



Found it, here is the correct code :

hr = pCont->Create(CComBSTR("person"), /*Relative Name*/CComBSTR("cn=JeffSmith"), &pDisp);
hr = pDisp->QueryInterface(IID_IADs, (void**) &pADs);
hr = pADs->Put(CComBSTR("sn"), CComVariant("JeffSmith"));
hr = pADs->Put(CComBSTR("cn"), CComVariant("JeffSmith"));
hr = pADs->SetInfo(); // Commit Ok

ADsGetLastError Error Text was "object class 'person' requires attribute 'cn'"

-----Message d'origine-----
De : Pierangelo Masarati [mailto:ando@sys-net.it] 
Envoyé : jeudi 3 juin 2004 09:25
À : Olivier MATROT
Cc : openLDAP-software@OpenLDAP.org
Objet : Re: Add an Entry with ADSI in C++


> I'm trying to create an entry of class 'person' in an OpenLDAP 
> directory using ADSI.
> I could not figure out why this is not working since the only required 
> attribute is 'sn'.
> Here is my code :
>
> HRESULT hr;
> IADsContainer *pCont = NULL;
> IADs *pADs = NULL;
> IDispatch *pDisp = NULL;
> CoInitialize(NULL);
> hr =
> ADsOpenObject(L"LDAP://192.168.3.118/dc=rtetest,dc=org",L"cn=administr
> at eur,dc=rtetest,dc=org", L"rtekb", 0, 
> IID_IADsContainer,(void**)&pCont);
> hr = pCont->Create(CComBSTR("person"), CComBSTR("cn=JeffSmith"), 
> &pDisp); hr = pDisp->QueryInterface(IID_IADs, (void**) &pADs); hr = 
> pADs->Put(CComBSTR("sn"), CComVariant("JeffSmith")); hr = 
> pADs->SetInfo(); // Error  0x80072014 the requested operation did not 
> satisfy one or more contraints associated with the object
>
>
> Any help appreciated

I suggest you carefully read the schema for objectClass person; you'll find out that "sn" is not the only required attribute; at least one more is explicitly required ("cn"), and another one is implicitly required; I'm not familiar with ADSI syntax, so I don't know if you're already adding it.

I suggest you ask ADSI specific fori for more specific info.

p.

--
Pierangelo Masarati
mailto:pierangelo.masarati@sys-net.it




    SysNet - via Dossi,8 27100 Pavia Tel: +390382573859 Fax: +390382476497