summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2015-01-14 12:36:24 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2015-01-14 12:38:13 +0100
commit68f70786d666836d3b1d850da17d3646839cfd01 (patch)
tree44e4f9e42c3b2359f7e712e816e1a54573e1c2d7
parente99f7c72196969fdda36c801c953662b84bd10b1 (diff)
downloadpykolab-68f70786d666836d3b1d850da17d3646839cfd01.tar.gz
Fall back on standard root dn determinations if no ldap/domain_filter setting exists (#4218).
-rw-r--r--pykolab/auth/ldap/__init__.py63
1 files changed, 32 insertions, 31 deletions
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index 0b51a74..07a20c8 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -2170,44 +2170,45 @@ class LDAP(pykolab.base.Base):
domain_filter = conf.get('ldap', 'domain_filter')
- if not domain == None:
- domain_filter = domain_filter.replace('*', domain)
-
- if not domain_base_dn == "":
-
- _results = self._search(
- domain_base_dn,
- ldap.SCOPE_SUBTREE,
- domain_filter,
- override_search='_regular_search'
- )
+ if not domain_filter == None:
+ if not domain == None:
+ domain_filter = domain_filter.replace('*', domain)
- domains = []
+ if not domain_base_dn == "":
- for _domain in _results:
- (domain_dn, _domain_attrs) = _domain
- domain_rootdn_attribute = conf.get(
- 'ldap',
- 'domain_rootdn_attribute'
+ _results = self._search(
+ domain_base_dn,
+ ldap.SCOPE_SUBTREE,
+ domain_filter,
+ override_search='_regular_search'
)
- _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:
- domain_name_attribute = self.config_get('domain_name_attribute')
- if domain_name_attribute == None:
- domain_name_attribute = 'associateddomain'
+ domains = []
+
+ for _domain in _results:
+ (domain_dn, _domain_attrs) = _domain
+ domain_rootdn_attribute = conf.get(
+ 'ldap',
+ 'domain_rootdn_attribute'
+ )
+ _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]
- if isinstance(_domain_attrs[domain_name_attribute], list):
- domain = _domain_attrs[domain_name_attribute][0]
else:
- domain = _domain_attrs[domain_name_attribute]
+ domain_name_attribute = self.config_get('domain_name_attribute')
+ if domain_name_attribute == None:
+ domain_name_attribute = 'associateddomain'
- else:
- if conf.has_option('ldap', 'base_dn'):
- return conf.get('ldap', 'base_dn')
+ 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')
self.domain_rootdns[domain] = utils.standard_root_dn(domain)
return self.domain_rootdns[domain]