ucs/listener.py
Jeroen van Meeuwen
vanmeeuwen at kolabsys.com
Mon Jun 24 13:54:24 CEST 2013
ucs/listener.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
New commits:
commit 8b29487df690465f8d5af924240b9152c3ec1874
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Mon Jun 24 12:53:38 2013 +0100
When a user is modified, we still need to take in to account the mail server attribute.
The same goes for deletion, but the deletion event notification does not necessarily contain a mail server attribute.
diff --git a/ucs/listener.py b/ucs/listener.py
index b0df053..37a346c 100755
--- a/ucs/listener.py
+++ b/ucs/listener.py
@@ -91,6 +91,32 @@ def handler(*args, **kw):
if isinstance(new, dict) and len(new.keys()) > 0:
log.info("Modify entry %r" % (dn))
+ mailserver_attribute = conf.get('ldap', 'mailserver_attribute').lower()
+
+ if mailserver_attribute == None:
+ log.error("Mail server attribute is not set")
+ return
+
+ if old.has_key(mailserver_attribute):
+ log.info("Modified entry %r has mail server attribute %s: %r" % (dn, mailserver_attribute, new[mailserver_attribute]))
+
+ if not old[mailserver_attribute] == constants.fqdn:
+ # Even though the new mailserver can be us, it is the
+ # *current* mail server that needs to push for the XFER.
+ log.info("The mail server for user %r is set, and it is not me (%r)" % (dn, old[mailserver_attribute))
+ return
+
+ else:
+ # If old has no mailserver attribute, but new does, we need to create
+ # the user locally.
+ if new.has_key(mailserver_attribute):
+ if not new[mailserver_attribute] == constants.fqdn:
+ log.info("The mail server for user %r is set (in new, not old), but it is not me (%r)" % (dn, new[mailserver_attribute]))
+ return
+ else:
+ log.info("Entry %r does not have a mail server attribute." % (dn))
+ return
+
auth._auth._synchronize_callback(
change_type = 'modify',
previous_dn = None,
@@ -102,6 +128,25 @@ def handler(*args, **kw):
else:
log.info("Delete entry %r" % (dn))
+ # See if the mailserver_attribute exists
+ mailserver_attribute = conf.get('ldap', 'mailserver_attribute').lower()
+
+ if mailserver_attribute == None:
+ log.error("Mail server attribute is not set")
+ # TODO: Perhaps, query for IMAP servers. If there is only one,
+ # we know what to do.
+ return
+
+ if old.has_key(mailserver_attribute):
+ log.info("Deleted entry %r has mail server attribute %s: %r" % (dn, mailserver_attribute, old[mailserver_attribute]))
+
+ if not old[mailserver_attribute] == constants.fqdn:
+ log.info("The mail server for user %r is set, and it is not me (%r)" % (dn, old[mailserver_attribute]))
+ return
+
+ else:
+ log.info("Entry deletion notification for %r does not have a mail server attribute specified." % (dn))
+
auth._auth._synchronize_callback(
change_type = 'delete',
previous_dn = None,
@@ -130,6 +175,10 @@ def handler(*args, **kw):
log.info("The mail server for user %r is set, and it is not me (%r)" % (dn, new[mailserver_attribute]))
return
+ else:
+ log.info("Added entry %r does not have a mail server attribute set." % (dn))
+ return
+
auth._auth._synchronize_callback(
change_type = 'add',
previous_dn = None,
More information about the commits
mailing list