3 commits - kolabd/__init__.py pykolab/auth
Jeroen van Meeuwen
vanmeeuwen at kolabsys.com
Wed Mar 18 14:07:41 CET 2015
kolabd/__init__.py | 4 ++
pykolab/auth/__init__.py | 3 ++
pykolab/auth/ldap/__init__.py | 62 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 68 insertions(+), 1 deletion(-)
New commits:
commit 9389961a04bc77a9ec9b82a3359e7fc7bba06016
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Wed Mar 18 14:05:41 2015 +0100
Use the new domain naming context comparison function to reduce the number of processes against hosted (#4260)
Domain name spaces are translated back to the domain that owns the naming context, and skipped a separate process for should the naming context already be synchronized by another process.
diff --git a/kolabd/__init__.py b/kolabd/__init__.py
index 92a929c..6a0fd32 100644
--- a/kolabd/__init__.py
+++ b/kolabd/__init__.py
@@ -248,7 +248,9 @@ class KolabDaemon(object):
# domains now is a list of tuples, we want the primary_domains
primary_domains = []
for primary_domain in list(set(domains.values())):
- primary_domains.append(primary_domain)
+ primary_domain = primary_auth.domain_naming_context(primary_domain)
+ if not primary_domain == None:
+ primary_domains.append(primary_domain)
# Now we can check if any changes happened.
added_domains = []
commit a4b80d320b42bec56a9b5154e1e005952b2affd2
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Wed Mar 18 14:05:30 2015 +0100
Proxy the new naming context function
diff --git a/pykolab/auth/__init__.py b/pykolab/auth/__init__.py
index 88b46bc..79d6561 100644
--- a/pykolab/auth/__init__.py
+++ b/pykolab/auth/__init__.py
@@ -271,6 +271,9 @@ class Auth(pykolab.base.Base):
def domain_default_quota(self, domain):
return self._auth._domain_default_quota(domain)
+ def domain_naming_context(self, domain):
+ return self._auth._domain_naming_context(domain)
+
def get_entry_attribute(self, domain, entry, attribute):
return self._auth.get_entry_attribute(entry, attribute)
commit 63c5d500b336f12e4a86543d553869522bc928cd
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Wed Mar 18 14:05:01 2015 +0100
Add a function to retrieve the naming context used for a given domain
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index dd477ef..fa01993 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -2031,6 +2031,68 @@ class LDAP(pykolab.base.Base):
self.ldap = None
self.bind = False
+ def _domain_naming_context(self, domain):
+ self._bind()
+
+ # The list of naming contexts in the LDAP server
+ attrs = self.get_entry_attributes("", ['namingContexts'])
+
+ naming_contexts = attrs['namingcontexts']
+
+ log.debug(
+ _("Naming contexts found: %r") % (naming_contexts),
+ level=8
+ )
+
+ self._kolab_domain_root_dn(domain)
+
+ log.debug(
+ _("Domains/Root DNs found: %r") % (
+ self.domain_rootdns
+ ),
+ level=8
+ )
+
+ # 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
+ )
+
+ 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):
"""
Tests if 'value' is a valid entry dictionary with a DN contained
More information about the commits
mailing list