summaryrefslogtreecommitdiffstats
path: root/ucs/listener.py
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-06-24 12:53:38 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-06-24 12:53:38 +0100
commit8b29487df690465f8d5af924240b9152c3ec1874 (patch)
tree8e820da0c3f96dfc15e4ae3f4389053067c522b1 /ucs/listener.py
parent515b1104bef8faccbfb5a9882e3f3224d6d5b0c5 (diff)
downloadpykolab-8b29487df690465f8d5af924240b9152c3ec1874.tar.gz
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.
Diffstat (limited to 'ucs/listener.py')
-rwxr-xr-xucs/listener.py49
1 files changed, 49 insertions, 0 deletions
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,