[ldap] take care, email address may be a list. In such case, only consider the first one (XXX). Also, fix call to reset_caches.
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 15 Jul 2010 10:43:19 +0200
changeset 5972 220856aff85e
parent 5971 6109bdb8ac06
child 5973 eaf305258bbe
[ldap] take care, email address may be a list. In such case, only consider the first one (XXX). Also, fix call to reset_caches.
server/sources/ldapuser.py
--- a/server/sources/ldapuser.py	Tue Jul 13 17:22:15 2010 +0200
+++ b/server/sources/ldapuser.py	Thu Jul 15 10:43:19 2010 +0200
@@ -232,6 +232,8 @@
                 if res:
                     ldapemailaddr = res[0].get(ldap_emailattr)
                     if ldapemailaddr:
+                        if isinstance(ldapemailaddr, list):
+                            ldapemailaddr = ldapemailaddr[0] # XXX consider only the first email in the list
                         rset = execute('Any X,A WHERE '
                                        'X address A, U use_email X, U eid %(u)s',
                                        {'u': eid})
@@ -522,7 +524,7 @@
                              eid, base)
                 entity = session.entity_from_eid(eid, 'CWUser')
                 self.repo.delete_info(session, entity, self.uri, base)
-                self.reset_cache()
+                self.reset_caches()
             return []
         # except ldap.REFERRAL, e:
         #     cnx = self.handle_referral(e)
@@ -589,6 +591,8 @@
             emailaddr = self._cache[dn][self.user_rev_attrs['email']]
         except KeyError:
             return
+        if isinstance(emailaddr, list):
+            emailaddr = emailaddr[0] # XXX consider only the first email in the list
         rset = session.execute('EmailAddress X WHERE X address %(addr)s',
                                {'addr': emailaddr})
         if rset: