From: Rakotomandimby M. <mih...@et...> - 2006-01-04 18:58:17
|
Hi, Following http://www.grotan.com/ldap/python-ldap-samples.html#add I made this: ############################################# import ldap import ldap.modlist as modlist moi="cn=Manager,dc=localdomain" l = ldap.initialize("ldap://localhost:389/") l.simple_bind_s(moi,"mypassword") attrs={} attrs['objectclass'] = ['top','organizationalRole','simpleSecurityObject'] attrs['cn'] = 'user1' attrs['userPassword'] = 'user1user1' attrs['description'] = 'User object for replication using slurpd' ldif = modlist.addModlist(attrs) dn="cn=user1,dc=localdomain" l.add_s(dn,ldif) ############################################# Ans I get this error: In [31]: l.add_s(dn,ldif) --------------------------------------------------------------------------- ldap.NO_SUCH_OBJECT Traceback (most recent call last) /home/mihamina/programmation/ldap/<console> /usr/lib/python2.4/site-packages/ldap/ldapobject.py in add_s(self, dn, modlist) 161 def add_s(self,dn,modlist): 162 msgid = self.add(dn,modlist) --> 163 self.result(msgid,all=1,timeout=self.timeout) 164 165 def simple_bind(self,who='',cred='',serverctrls=None,clientctrls=None): /usr/lib/python2.4/site-packages/ldap/ldapobject.py in result(self, msgid, all, timeout) 397 polling (timeout = 0), in which case (None, None) is returned. 398 """ --> 399 res_type,res_data,res_msgid = self.result2(msgid,all,timeout) 400 return res_type,res_data 401 /usr/lib/python2.4/site-packages/ldap/ldapobject.py in result2(self, msgid, all, timeout) 403 if timeout is None: 404 timeout = self.timeout --> 405 return self._ldap_call(self._l.result2,msgid,all,timeout) 406 407 def search_ext(self,base,scope,filterstr='(objectClass=*)',attrlist=None,attrsonly=0,serverctrls=None,clientctrls=None,timeout=-1,sizelimit=0): /usr/lib/python2.4/site-packages/ldap/ldapobject.py in _ldap_call(self, func, *args, **kwargs) 92 try: 93 try: ---> 94 result = func(*args,**kwargs) 95 finally: 96 self._ldap_object_lock.release() NO_SUCH_OBJECT: {'info': '', 'desc': 'No such object'} -- A powerfull GroupWare, CMS, CRM, ECM: CPS (Open Source & GPL). Opengroupware, SPIP, Plone, PhpBB, JetSpeed... are good: CPS is better. http://www.cps-project.org for downloads & documentation. Free hosting of CPS groupware: http://www.objectis.org. |
From: Bjorn O. G. <bjo...@it...> - 2006-01-04 21:54:02
|
Rakotomandimby Mihamina: > Hi, > Following > http://www.grotan.com/ldap/python-ldap-samples.html#add >=20 > I made this: >=20 > ############################################# > import ldap > import ldap.modlist as modlist > moi=3D"cn=3DManager,dc=3Dlocaldomain" > l =3D ldap.initialize("ldap://localhost:389/") > l.simple_bind_s(moi,"mypassword") > attrs=3D{} > attrs['objectclass'] =3D > ['top','organizationalRole','simpleSecurityObject'] > attrs['cn'] =3D 'user1' > attrs['userPassword'] =3D 'user1user1' > attrs['description'] =3D 'User object for replication using slurpd' > ldif =3D modlist.addModlist(attrs) > dn=3D"cn=3Duser1,dc=3Dlocaldomain" Do you even have the parent entry in your database? e.g this ldif-representation: # Top root node in your D.I.T dn: dc=3Dlocaldomain objectClass: top objectClass: dcObject dc: localdomain if not, try add it with ldapadd or slapadd from commandline first. I find it very handy to try making shure I'm able to do the most basic things with commandline tools if I get any errors that don't make sence to me using the ldap-api directly. Its a good excersize to play around with ldapadd and ldapmodify working with plain old ldif-files on commandline to get the grips of how LDAP works. > l.add_s(dn,ldif) > ############################################# >=20 > Ans I get this error: >=20 > In [31]: l.add_s(dn,ldif) > -----------------------------------------------------------------------= ---- > ldap.NO_SUCH_OBJECT Traceback (most recent > call last) --=20 regards =20 Bj=F8rn Ove Gr=F8tan |
From: Rakotomandimby M. <mih...@et...> - 2006-01-04 22:42:23
|
> Do you even have the parent entry in your database? e.g this > ldif-representation: > > # Top root node in your D.I.T > dn: dc=localdomain > objectClass: top > objectClass: dcObject > dc: localdomain > > if not, try add it with ldapadd or slapadd from commandline first. Well. I did not have it. You're right. > I find it very handy to try making shure I'm able to do the most basic > things with commandline tools if I get any errors that don't make > sence to me using the ldap-api directly. > Its a good excersize to play around with ldapadd and ldapmodify working > with plain old ldif-files on commandline to get the grips of how LDAP > works. It's a point of view. The "low-level->high-level" is a good idea to me. But some of our teachers think that the best one would be "high-level->low-level". That is why they introduce algorithm and programation with OCaml and or Python but not with C. As well as you are here and advice me, I wil follow you, but my teachers tell me the opposite :-) Thank you for your help anyway. -- A powerfull GroupWare, CMS, CRM, ECM: CPS (Open Source & GPL). Opengroupware, SPIP, Plone, PhpBB, JetSpeed... are good: CPS is better. http://www.cps-project.org for downloads & documentation. Free hosting of CPS groupware: http://www.objectis.org. |