summaryrefslogtreecommitdiffstats
path: root/pykolab
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 /pykolab
parentf77cbb401b48109258c6ed8d09151e7254bee4ad (diff)
downloadpykolab-7ea7399a6d32f65fe670e8e31b60f22bd2132fd2.tar.gz
Correct detecting naming contexts for databases to synchronize against, and using parent domain name spaces for synchronization
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/auth/ldap/__init__.py45
1 files changed, 8 insertions, 37 deletions
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):