summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-09-20 14:08:51 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-09-20 14:08:51 (GMT)
commit55d43ba9bf0364dade6e9510c7eaea33695b92b2 (patch)
treee170a077a5e871b1e5759a3c2becdecf4f8c601e
parent91d7125c2e2b64634dfc376e7b9856fda6bddfa7 (diff)
downloadpykolab-55d43ba9bf0364dade6e9510c7eaea33695b92b2.tar.gz
Adapt to the new logic of storing domain parameters
-rw-r--r--pykolab/auth/__init__.py44
1 files changed, 24 insertions, 20 deletions
diff --git a/pykolab/auth/__init__.py b/pykolab/auth/__init__.py
index ea8cea6..5c6d51c 100644
--- a/pykolab/auth/__init__.py
+++ b/pykolab/auth/__init__.py
@@ -99,7 +99,7 @@ class Auth(pykolab.base.Base):
section = 'kolab'
domain = conf.get('kolab', 'primary_domain')
else:
- self.list_domains()
+ self.list_domains(domain)
section = domain
log.debug(
@@ -107,9 +107,9 @@ class Auth(pykolab.base.Base):
level=9
)
- if self.secondary_domains.has_key(domain):
- section = self.secondary_domains[domain]
- domain = self.secondary_domains[domain]
+ if not self.domains == None and self.domains.has_key(domain):
+ section = self.domains[domain]
+ domain = self.domains[domain]
log.debug(
_("Using section %s and domain %s") % (section,domain),
@@ -207,7 +207,7 @@ class Auth(pykolab.base.Base):
def find_user(self, attr, value, **kw):
return self._auth._find_user(attr, value, **kw)
- def list_domains(self):
+ def list_domains(self, domain=None):
"""
List the domains using the auth_mechanism setting in the kolab
section of the configuration file, either ldap or sql or (...).
@@ -225,23 +225,27 @@ class Auth(pykolab.base.Base):
# Find the domains in the authentication backend.
kolab_primary_domain = conf.get('kolab', 'primary_domain')
- try:
- domains = self._auth._list_domains()
- except:
- if not self.domain == kolab_primary_domain:
- return [(self.domain, [])]
- else:
- domains = []
+ if self.domains == None:
- # If no domains are found, the primary domain is used.
- if len(domains) < 1:
- domains = [(kolab_primary_domain, [])]
- else:
- for primary, secondaries in domains:
- for secondary in secondaries:
- self.secondary_domains[secondary] = primary
+ try:
+ domains = self._auth._list_domains(domain)
+ except:
+ if not self.domain == kolab_primary_domain:
+ return { self.domain: [] }
+ else:
+ domains = []
+
+ # If no domains are found, the primary domain is used.
+ if len(domains) < 1:
+ self.domains = { kolab_primary_domain: [] }
+ else:
+ self.domains = {}
+ for primary, secondaries in domains:
+ self.domains[primary] = primary
+ for secondary in secondaries:
+ self.domains[secondary] = primary
- return domains
+ return self.domains
def synchronize(self, mode=0):
self._auth.synchronize(mode=mode)