check ldap source has email configured before synchronization
authorsylvain.thenault@logilab.fr
Tue, 24 Feb 2009 20:59:28 +0100
changeset 938 a69188963ccb
parent 937 491dbd818f9b
child 948 c95ce9b38168
check ldap source has email configured before synchronization
server/sources/ldapuser.py
--- a/server/sources/ldapuser.py	Tue Feb 24 20:59:07 2009 +0100
+++ b/server/sources/ldapuser.py	Tue Feb 24 20:59:28 2009 +0100
@@ -176,6 +176,10 @@
         external repository
         """
         self.info('synchronizing ldap source %s', self.uri)
+        try:
+            ldap_emailattr = self.user_rev_attrs['email']
+        except KeyError:
+            return # no email in ldap, we're done
         session = self.repo.internal_session()
         try:
             cursor = session.system_sql("SELECT eid, extid FROM entities WHERE "
@@ -184,7 +188,7 @@
                 # if no result found, _search automatically delete entity information
                 res = self._search(session, extid, BASE)
                 if res: 
-                    ldapemailaddr = res[0].get(self.user_rev_attrs['email'])
+                    ldapemailaddr = res[0].get(ldap_emailattr)
                     if ldapemailaddr:
                         rset = session.execute('EmailAddress X,A WHERE '
                                                'U use_email X, U eid %(u)s',