summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-09-18 15:34:31 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-01-18 18:18:53 +0100
commitca01db2cc0c6035a47ee8f311e5a0a58a9a66832 (patch)
treed45efa331eca7c4ace126908b7a9633ae0461675
parent449bff5693099c85751a7c50759e957683b249b2 (diff)
downloadpykolab-ca01db2cc0c6035a47ee8f311e5a0a58a9a66832.tar.gz
Store a domain's root dn once it is found, so that subsequent actions against the same base sub-class instance do not need to search again and again
-rw-r--r--pykolab/auth/ldap/__init__.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index 69af8c7..266a5d7 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -1637,6 +1637,12 @@ class LDAP(pykolab.base.Base):
return _user_dn
def _kolab_domain_root_dn(self, domain):
+ if not hasattr(self, 'domain_rootdns'):
+ self.domain_rootdns = {}
+
+ if self.domain_rootdns.has_key(domain):
+ return self.domain_rootdns[domain]
+
self._bind()
log.debug(_("Finding domain root dn for domain %s") % (domain), level=8)
@@ -1667,16 +1673,19 @@ class LDAP(pykolab.base.Base):
)
_domain_attrs = utils.normalize(_domain_attrs)
if _domain_attrs.has_key(domain_rootdn_attribute):
+ self.domain_rootdns[domain] = _domain_attrs[domain_rootdn_attribute]
return _domain_attrs[domain_rootdn_attribute]
else:
if isinstance(_domain_attrs[domain_name_attribute], list):
domain = _domain_attrs[domain_name_attribute][0]
-
+ else:
+ domain = _domain_attrs[domain_name_attribute]
else:
if conf.has_option('ldap', 'base_dn'):
return conf.get('ldap', 'base_dn')
- return utils.standard_root_dn(domain)
+ self.domain_rootdns[domain] = utils.standard_root_dn(domain)
+ return self.domain_rootdns[domain]
def _kolab_filter(self):
"""