summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2015-08-14 10:05:42 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2015-08-14 10:05:42 +0200
commit7ea7399a6d32f65fe670e8e31b60f22bd2132fd2 (patch)
treec127ea8bc856bcb73c24f81a2ec87f7e9d5cb74f
parentf77cbb401b48109258c6ed8d09151e7254bee4ad (diff)
downloadpykolab-7ea7399a6d32f65fe670e8e31b60f22bd2132fd2.tar.gz
Correct detecting naming contexts for databases to synchronize against, and using parent domain name spaces for synchronization
-rw-r--r--kolabd/__init__.py22
-rw-r--r--pykolab/auth/ldap/__init__.py45
2 files changed, 26 insertions, 41 deletions
diff --git a/kolabd/__init__.py b/kolabd/__init__.py
index 26d6001..7ed2c9d 100644
--- a/kolabd/__init__.py
+++ b/kolabd/__init__.py
@@ -270,13 +270,18 @@ class KolabDaemon(object):
# domains now is a list of tuples in the format of
# ('primary',[secondaries]), we want the primary_domains
+ domain_base_dns = []
primary_domains = []
- for primary_domain, secondaries in domains:
+ for primary_domain, secondaries in domains.iteritems():
domain_base_dn = primary_auth.domain_naming_context(primary_domain)
+ log.debug(_("Domain Base DN for domain %r is %r") % (primary_domain, domain_base_dn), level=8)
if not domain_base_dn == None:
- if not domain_base_dn in primary_domains:
- primary_domains.append(domain_base_dn)
+ if not domain_base_dn in domain_base_dns:
+ domain_base_dns.append(domain_base_dn)
+ primary_domains.append(primary_domain)
+
+ log.debug(_("Naming contexts to synchronize: %r") % (primary_domains), level=8)
# Now we can check if any changes happened.
added_domains = []
@@ -284,18 +289,27 @@ class KolabDaemon(object):
# Combine the domains from LDAP with the domain processes
# accounted for locally.
- all_domains = set(primary_domains + domain_auth.keys())
+ all_domains = list(set(primary_domains + domain_auth.keys()))
+
+ log.debug(_("All naming contexts: %r") % (all_domains), level=8)
for domain in all_domains:
+ log.debug(_("Checking for domain %s") % (domain), level=8)
+
if domain in domain_auth.keys() and domain in primary_domains:
if not domain_auth[domain].is_alive():
+ log.debug(_("Domain %s isn't alive anymore.") % (domain), level=8)
domain_auth[domain].terminate()
added_domains.append(domain)
else:
+ log.debug(_("Domain %s already there and alive.") % (domain), level=8)
continue
+
elif domain in domain_auth.keys():
+ log.debug(_("Domain %s should not exist any longer.") % (domain), level=8)
removed_domains.append(domain)
else:
+ log.debug(_("Domain %s does not have a process yet.") % (domain), level=8)
added_domains.append(domain)
if len(removed_domains) == 0 and len(added_domains) == 0:
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index 1fe8eb5..5b4f31f 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -2100,44 +2100,9 @@ class LDAP(pykolab.base.Base):
)
# If we have a 1:1 match, continue as planned
- if self.domain_rootdns.has_key(domain):
- if self.domain_rootdns[domain] in naming_contexts:
- log.debug(
- _("Domain '%s' has a root dn all by itself, namely '%s'") % (
- domain,
- self.domain_rootdns[domain]
- ),
- level=8
- )
-
- return domain
-
- else:
- naming_context = ''.join(
- [x for x in self.domain_rootdns.keys() \
- if self.domain_rootdns[x] in \
- [y for y in naming_contexts \
- if self.domain_rootdns[domain].endswith(y) \
- ] \
- ]
- )
-
- log.debug(
- _("Domain '%s' has a base dn residing inside root dn '%s'") % (
- domain,
- naming_context
- ),
- level=8
- )
-
+ for naming_context in naming_contexts:
+ if self.domain_rootdns[domain].endswith(naming_context):
return naming_context
- else:
- # Should not end up here
- log.error(
- _("Could not find a naming context for domain '%s'") % (domain)
- )
-
- return None
def _entry_dict(self, value):
"""
@@ -2278,10 +2243,12 @@ class LDAP(pykolab.base.Base):
return _user_dn
def _kolab_domain_root_dn(self, domain):
+ log.debug(_("Searching root dn for domain %r") % (domain), level=8)
if not hasattr(self, 'domain_rootdns'):
self.domain_rootdns = {}
if self.domain_rootdns.has_key(domain):
+ log.debug(_("Returning from cache: %r") % (self.domain_rootdns[domain]), level=8)
return self.domain_rootdns[domain]
self._bind()
@@ -2316,8 +2283,11 @@ class LDAP(pykolab.base.Base):
'ldap',
'domain_rootdn_attribute'
)
+
_domain_attrs = utils.normalize(_domain_attrs)
+
if _domain_attrs.has_key(domain_rootdn_attribute):
+ log.debug(_("Setting domain root dn from LDAP for domain %r: %r") % (domain, _domain_attrs[domain_rootdn_attribute]), level=8)
self.domain_rootdns[domain] = _domain_attrs[domain_rootdn_attribute]
return _domain_attrs[domain_rootdn_attribute]
@@ -2336,6 +2306,7 @@ class LDAP(pykolab.base.Base):
return conf.get('ldap', 'base_dn')
self.domain_rootdns[domain] = utils.standard_root_dn(domain)
+
return self.domain_rootdns[domain]
def _kolab_filter(self):