##// END OF EJS Templates
ldap: handle more elegantly that python-ldap isn't installed when trying to use ldap...
Mads Kiilerich -
r3632:1ec67ddc beta
parent child Browse files
Show More
@@ -40,7 +40,8 b' from rhodecode import __platform__, is_w'
40 from rhodecode.model.meta import Session
40 from rhodecode.model.meta import Session
41
41
42 from rhodecode.lib.utils2 import str2bool, safe_unicode
42 from rhodecode.lib.utils2 import str2bool, safe_unicode
43 from rhodecode.lib.exceptions import LdapPasswordError, LdapUsernameError
43 from rhodecode.lib.exceptions import LdapPasswordError, LdapUsernameError,\
44 LdapImportError
44 from rhodecode.lib.utils import get_repo_slug, get_repos_group_slug
45 from rhodecode.lib.utils import get_repo_slug, get_repos_group_slug
45 from rhodecode.lib.auth_ldap import AuthLdap
46 from rhodecode.lib.auth_ldap import AuthLdap
46
47
@@ -241,7 +242,7 b' def authenticate(username, password):'
241
242
242 Session().commit()
243 Session().commit()
243 return True
244 return True
244 except (LdapUsernameError, LdapPasswordError,):
245 except (LdapUsernameError, LdapPasswordError, LdapImportError):
245 pass
246 pass
246 except (Exception,):
247 except (Exception,):
247 log.error(traceback.format_exc())
248 log.error(traceback.format_exc())
@@ -26,7 +26,7 b''
26 import logging
26 import logging
27
27
28 from rhodecode.lib.exceptions import LdapConnectionError, LdapUsernameError, \
28 from rhodecode.lib.exceptions import LdapConnectionError, LdapUsernameError, \
29 LdapPasswordError
29 LdapPasswordError, LdapImportError
30 from rhodecode.lib.utils2 import safe_str
30 from rhodecode.lib.utils2 import safe_str
31
31
32 log = logging.getLogger(__name__)
32 log = logging.getLogger(__name__)
@@ -36,7 +36,7 b' try:'
36 import ldap
36 import ldap
37 except ImportError:
37 except ImportError:
38 # means that python-ldap is not installed
38 # means that python-ldap is not installed
39 pass
39 ldap = None
40
40
41
41
42 class AuthLdap(object):
42 class AuthLdap(object):
@@ -45,6 +45,9 b' class AuthLdap(object):'
45 tls_kind='PLAIN', tls_reqcert='DEMAND', ldap_version=3,
45 tls_kind='PLAIN', tls_reqcert='DEMAND', ldap_version=3,
46 ldap_filter='(&(objectClass=user)(!(objectClass=computer)))',
46 ldap_filter='(&(objectClass=user)(!(objectClass=computer)))',
47 search_scope='SUBTREE', attr_login='uid'):
47 search_scope='SUBTREE', attr_login='uid'):
48 if ldap is None:
49 raise LdapImportError
50
48 self.ldap_version = ldap_version
51 self.ldap_version = ldap_version
49 ldap_server_type = 'ldap'
52 ldap_server_type = 'ldap'
50
53
General Comments 0
You need to be logged in to leave comments. Login now