From: <jph...@fr...> - 2007-02-19 08:08:47
|
Hi, I was used to work with phpldapadmin, then discovered luma. Now I need something more specific to my needs, and thus interested in python-ldap. Starting was really easy :-) Unfortunately, I discovered a bug in my application this week-end: I can not use 8 bits chars in search or add functions while I have no issue with these characters in Luma :-( It seems to be related to string encoding. Luma makes an intensive use of the "unicode" function. So I tried that piece of code but without success: >>> import ldap >>> CON=ldap.open('localhost.localdomain') >>> CON.simple_bind_s('','') >>> CON.search_s('ou=amis,dc=localdomain',ldap.SCOPE_SUBTREE,u'(cn=th') exceptions.UnicodeEncodeError Traceback (most recent call last) /home/jpht/informatique/programmation/python/scripts/under_development/<console> /usr/lib/python2.3/site-packages/ldap/ldapobject.py in search_s(self, base, scope, filterstr, attrlist, attrsonly) 466 467 def search_s(self,base,scope,filterstr='(objectClass=*)',attrlist=None,attrsonly=0): --> 468 return self.search_ext_s(base,scope,filterstr,attrlist,attrsonly,timeout=self.timeout) 469 470 def search_st(self,base,scope,filterstr='(objectClass=*)',attrlist=None,attrsonly=0,timeout=-1): /usr/lib/python2.3/site-packages/ldap/ldapobject.py in search_ext_s(self, base, scope, filterstr, attrlist, attrsonly, serverctrls, clientctrls, timeout, sizelimit) 459 460 def search_ext_s(self,base,scope,filterstr='(objectClass=*)',attrlist=None,attrsonly=0,serverctrls=None,clientctrls=None,timeout=-1,sizelimit=0): --> 461 msgid = self._ldap_call(self._l.search_ext,base,scope,filterstr,attrlist,attrsonly,serverctrls,clientctrls,timeout,sizelimit) 462 return self.result(msgid,all=1,timeout=timeout)[1] 463 /usr/lib/python2.3/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() UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 6: ordinal not in range(128) I went quickly through this list, but was not sure of understanding the answer ;-( Could someone help me? Jean-Philippe P.S.: I am running slapd 2.2.23 and python-ldap 2.0.4 (debian sarge) |