Changeset View
Changeset View
Standalone View
Standalone View
pykolab/auth/ldap/__init__.py
Show First 20 Lines • Show All 641 Lines • ▼ Show 20 Lines | def find_folder_resource(self, folder="*", exclude_entry_id=None): | ||||
_filter = "%s%s%s" % (__filter_prefix, _filter, __filter_suffix) | _filter = "%s%s%s" % (__filter_prefix, _filter, __filter_suffix) | ||||
log.debug(_l("Finding resource with filter %r") % (_filter), level=8) | log.debug(_l("Finding resource with filter %r") % (_filter), level=8) | ||||
if len(_filter) <= 6: | if len(_filter) <= 6: | ||||
return None | return None | ||||
config_base_dn = self.config_get('resource_base_dn') | resource_base_dn = self._object_base_dn('resource') | ||||
ldap_base_dn = self._kolab_domain_root_dn(self.domain) | |||||
if ldap_base_dn is not None and not ldap_base_dn == config_base_dn: | |||||
resource_base_dn = ldap_base_dn | |||||
else: | |||||
resource_base_dn = config_base_dn | |||||
_results = self.ldap.search_s( | _results = self.ldap.search_s( | ||||
resource_base_dn, | resource_base_dn, | ||||
scope=ldap.SCOPE_SUBTREE, | scope=ldap.SCOPE_SUBTREE, | ||||
filterstr=_filter, | filterstr=_filter, | ||||
attrlist=result_attributes, | attrlist=result_attributes, | ||||
attrsonly=True | attrsonly=True | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | def find_resource(self, address="*", exclude_entry_id=None): | ||||
_filter = "%s%s%s" % (__filter_prefix, _filter, __filter_suffix) | _filter = "%s%s%s" % (__filter_prefix, _filter, __filter_suffix) | ||||
log.debug(_l("Finding resource with filter %r") % (_filter), level=8) | log.debug(_l("Finding resource with filter %r") % (_filter), level=8) | ||||
if len(_filter) <= 6: | if len(_filter) <= 6: | ||||
return None | return None | ||||
config_base_dn = self.config_get('resource_base_dn') | resource_base_dn = self._object_base_dn('resource') | ||||
ldap_base_dn = self._kolab_domain_root_dn(self.domain) | |||||
if ldap_base_dn is not None and not ldap_base_dn == config_base_dn: | |||||
resource_base_dn = ldap_base_dn | |||||
else: | |||||
resource_base_dn = config_base_dn | |||||
_results = self.ldap.search_s( | _results = self.ldap.search_s( | ||||
resource_base_dn, | resource_base_dn, | ||||
scope=ldap.SCOPE_SUBTREE, | scope=ldap.SCOPE_SUBTREE, | ||||
filterstr=_filter, | filterstr=_filter, | ||||
attrlist=result_attributes, | attrlist=result_attributes, | ||||
attrsonly=True | attrsonly=True | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 1,646 Lines • ▼ Show 20 Lines | |||||
def _find_user_dn(self, login, kolabuser=False): | def _find_user_dn(self, login, kolabuser=False): | ||||
""" | """ | ||||
Find the distinguished name (DN) for a (Kolab) user entry in LDAP. | Find the distinguished name (DN) for a (Kolab) user entry in LDAP. | ||||
""" | """ | ||||
conf_prefix = 'kolab_' if kolabuser else '' | conf_prefix = 'kolab_' if kolabuser else '' | ||||
user_base_dn = self.config_get(conf_prefix + 'user_base_dn') | user_base_dn = self._object_base_dn('user', conf_prefix) | ||||
if user_base_dn is None: | |||||
user_base_dn = self.config_get('base_dn') | |||||
auth_attrs = self.config_get_list('auth_attributes') | auth_attrs = self.config_get_list('auth_attributes') | ||||
auth_search_filter = ['(|'] | auth_search_filter = ['(|'] | ||||
for auth_attr in auth_attrs: | for auth_attr in auth_attrs: | ||||
auth_search_filter.append('(%s=%s)' % (auth_attr, login)) | auth_search_filter.append('(%s=%s)' % (auth_attr, login)) | ||||
if '@' not in login: | if '@' not in login: | ||||
▲ Show 20 Lines • Show All 195 Lines • ▼ Show 20 Lines | def _list_domains(self, domain=None): | ||||
secondary_domains = [x.lower() for x in domain_attrs[dna]] | secondary_domains = [x.lower() for x in domain_attrs[dna]] | ||||
else: | else: | ||||
primary_domain = domain_attrs[dna].lower() | primary_domain = domain_attrs[dna].lower() | ||||
domains.append((primary_domain, secondary_domains)) | domains.append((primary_domain, secondary_domains)) | ||||
return domains | return domains | ||||
def _object_base_dn(self, objectType, prefix=''): | |||||
""" | |||||
Get configured base DN for specified Kolab object type | |||||
""" | |||||
object_base_dn = self.config_get(prefix + objectType + '_base_dn') | |||||
config_base_dn = self.config_get('base_dn') | |||||
ldap_base_dn = self._kolab_domain_root_dn(self.domain) | |||||
if ldap_base_dn is not None and not ldap_base_dn == config_base_dn: | |||||
base_dn = ldap_base_dn | |||||
else: | |||||
base_dn = config_base_dn | |||||
if object_base_dn is None: | |||||
object_base_dn = base_dn | |||||
else: | |||||
object_base_dn = object_base_dn % ({'base_dn': base_dn}) | |||||
return object_base_dn | |||||
def _synchronize_callback(self, *args, **kw): | def _synchronize_callback(self, *args, **kw): | ||||
""" | """ | ||||
Determine the characteristics of the callback being placed, and | Determine the characteristics of the callback being placed, and | ||||
what data is contained within *args and **kw exactly. | what data is contained within *args and **kw exactly. | ||||
The exact form and shape of the feedback very much depends on the | The exact form and shape of the feedback very much depends on the | ||||
supportedControl used to even get the data. | supportedControl used to even get the data. | ||||
""" | """ | ||||
▲ Show 20 Lines • Show All 567 Lines • Show Last 20 Lines |