summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-09-18 14:34:31 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-09-18 14:34:31 (GMT)
commit65e8189af3c1cb9bb9c623cd7592eddeb356f5e8 (patch)
tree3e5f5bbefd7a8ddbdfb7624bfc7520228bf6ba48
parent9017334c9304b945d6838816cc4d6fab731df6a4 (diff)
downloadpykolab-65e8189af3c1cb9bb9c623cd7592eddeb356f5e8.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 cdb9ade..78a505f 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -1933,6 +1933,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)
@@ -1963,16 +1969,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):
"""