server/sources/ldapuser.py
changeset 938 a69188963ccb
parent 257 4c7d3af7e94d
child 975 0928daea04e9
--- 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',