Fix LDAP error and url handling to be more clear for the end user
This commit is contained in:
parent
6d7a95b019
commit
360aa69d92
2 changed files with 12 additions and 1 deletions
|
@ -232,12 +232,17 @@ def _validate_ldap(config):
|
|||
raise Exception('Missing Admin Password for LDAP configuration')
|
||||
|
||||
ldap_uri = config.get('LDAP_URI', 'ldap://localhost')
|
||||
if not ldap_uri.startswith('ldap://') and not ldap_uri.startswith('ldaps://'):
|
||||
raise Exception('LDAP URI must start with ldap:// or ldaps://')
|
||||
|
||||
try:
|
||||
with LDAPConnection(ldap_uri, admin_dn, admin_passwd):
|
||||
pass
|
||||
except ldap.LDAPError as ex:
|
||||
values = ex.args[0] if ex.args else {}
|
||||
if not isinstance(values, dict):
|
||||
raise Exception(str(ex.args))
|
||||
|
||||
raise Exception(values.get('desc', 'Unknown error'))
|
||||
|
||||
|
||||
|
|
Reference in a new issue