Changeset View
Changeset View
Standalone View
Standalone View
pykolab/auth/ldap/__init__.py
Show First 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | def authenticate(self, login, realm): | ||||
# Attempt to obtain an entry_dn from cache. | # Attempt to obtain an entry_dn from cache. | ||||
try: | try: | ||||
entry_dn = auth_cache.get_entry(_filter) | entry_dn = auth_cache.get_entry(_filter) | ||||
except Exception as errmsg: | except Exception as errmsg: | ||||
log.error(_l("Authentication cache failed: %r") % (errmsg)) | log.error(_l("Authentication cache failed: %r") % (errmsg)) | ||||
retval = False | retval = False | ||||
timeout = self.config_get('ldap', 'timeout', default=10) | timeout = float(self.config_get('ldap', 'timeout', default=10)) | ||||
if entry_dn is None: | if entry_dn is None: | ||||
_search = self.ldap.search_ext( | _search = self.ldap.search_ext( | ||||
base_dn, | base_dn, | ||||
ldap.SCOPE_SUBTREE, | ldap.SCOPE_SUBTREE, | ||||
filterstr=_filter, | filterstr=_filter, | ||||
attrlist=['entrydn'], | attrlist=['entrydn'], | ||||
attrsonly=True, | attrsonly=True, | ||||
▲ Show 20 Lines • Show All 2,860 Lines • ▼ Show 20 Lines | def _regular_search( | ||||
attrsonly=0, | attrsonly=0, | ||||
timeout=None, | timeout=None, | ||||
callback=False, | callback=False, | ||||
primary_domain=None, | primary_domain=None, | ||||
secondary_domains=[] | secondary_domains=[] | ||||
): | ): | ||||
if timeout is None: | if timeout is None: | ||||
timeout = self.config_get('ldap', 'timeout', 10) | timeout = float(self.config_get('ldap', 'timeout', default=10)) | ||||
log.debug(_l("Searching with filter %r") % (filterstr), level=8) | log.debug(_l("Searching with filter %r") % (filterstr), level=8) | ||||
_search = self.ldap.search( | _search = self.ldap.search( | ||||
base_dn, | base_dn, | ||||
scope=scope, | scope=scope, | ||||
filterstr=filterstr, | filterstr=filterstr, | ||||
attrlist=attrlist, | attrlist=attrlist, | ||||
Show All 28 Lines | ): | ||||
""" | """ | ||||
Search LDAP. | Search LDAP. | ||||
Use the priority ordered SUPPORTED_LDAP_CONTROLS and use | Use the priority ordered SUPPORTED_LDAP_CONTROLS and use | ||||
the first one supported. | the first one supported. | ||||
""" | """ | ||||
if timeout is None: | if timeout is None: | ||||
timeout = self.config_get('timeout', default=10) | timeout = float(self.config_get('ldap', 'timeout', default=10)) | ||||
supported_controls = conf.get_list('ldap', 'supported_controls') | supported_controls = conf.get_list('ldap', 'supported_controls') | ||||
if supported_controls is not None and not len(supported_controls) < 1: | if supported_controls is not None and not len(supported_controls) < 1: | ||||
for control_num in [(int)(x) for x in supported_controls]: | for control_num in [(int)(x) for x in supported_controls]: | ||||
self.ldap.supported_controls.append( | self.ldap.supported_controls.append( | ||||
SUPPORTED_LDAP_CONTROLS[control_num]['func'] | SUPPORTED_LDAP_CONTROLS[control_num]['func'] | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 132 Lines • Show Last 20 Lines |