mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Report the actual error when ldap fails
This commit is contained in:
parent
6391ef23c4
commit
d94832ec3d
2 changed files with 23 additions and 13 deletions
|
@ -19,7 +19,6 @@
|
||||||
"invalid_password": "Invalid password",
|
"invalid_password": "Invalid password",
|
||||||
"invalid_usage": "Invalid usage, pass --help to see help",
|
"invalid_usage": "Invalid usage, pass --help to see help",
|
||||||
"ldap_attribute_already_exists": "Attribute '{attribute}' already exists with value '{value}'",
|
"ldap_attribute_already_exists": "Attribute '{attribute}' already exists with value '{value}'",
|
||||||
"ldap_operation_error": "An error occurred during LDAP operation",
|
|
||||||
"ldap_server_down": "Unable to reach LDAP server",
|
"ldap_server_down": "Unable to reach LDAP server",
|
||||||
"logged_in": "Logged in",
|
"logged_in": "Logged in",
|
||||||
"logged_out": "Logged out",
|
"logged_out": "Logged out",
|
||||||
|
|
|
@ -141,9 +141,12 @@ class Authenticator(BaseAuthenticator):
|
||||||
try:
|
try:
|
||||||
result = self.con.search_s(base, ldap.SCOPE_SUBTREE, filter, attrs)
|
result = self.con.search_s(base, ldap.SCOPE_SUBTREE, filter, attrs)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception("error during LDAP search operation with: base='%s', "
|
raise MoulinetteError(
|
||||||
"filter='%s', attrs=%s and exception %s", base, filter, attrs, e)
|
"error during LDAP search operation with: base='%s', "
|
||||||
raise MoulinetteError('ldap_operation_error')
|
"filter='%s', attrs=%s and exception %s"
|
||||||
|
% (base, filter, attrs, e),
|
||||||
|
raw_msg=True
|
||||||
|
)
|
||||||
|
|
||||||
result_list = []
|
result_list = []
|
||||||
if not attrs or 'dn' not in attrs:
|
if not attrs or 'dn' not in attrs:
|
||||||
|
@ -172,9 +175,12 @@ class Authenticator(BaseAuthenticator):
|
||||||
try:
|
try:
|
||||||
self.con.add_s(dn, ldif)
|
self.con.add_s(dn, ldif)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception("error during LDAP add operation with: rdn='%s', "
|
raise MoulinetteError(
|
||||||
"attr_dict=%s and exception %s", rdn, attr_dict, e)
|
"error during LDAP add operation with: rdn='%s', "
|
||||||
raise MoulinetteError('ldap_operation_error')
|
"attr_dict=%s and exception %s"
|
||||||
|
% (rdn, attr_dict, e),
|
||||||
|
raw_msg=True
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -193,8 +199,11 @@ class Authenticator(BaseAuthenticator):
|
||||||
try:
|
try:
|
||||||
self.con.delete_s(dn)
|
self.con.delete_s(dn)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception("error during LDAP delete operation with: rdn='%s' and exception %s", rdn, e)
|
raise MoulinetteError(
|
||||||
raise MoulinetteError('ldap_operation_error')
|
"error during LDAP delete operation with: rdn='%s' and exception %s"
|
||||||
|
% (rdn, e),
|
||||||
|
raw_msg=True
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -226,10 +235,12 @@ class Authenticator(BaseAuthenticator):
|
||||||
|
|
||||||
self.con.modify_ext_s(dn, ldif)
|
self.con.modify_ext_s(dn, ldif)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception("error during LDAP update operation with: rdn='%s', "
|
raise MoulinetteError(
|
||||||
"attr_dict=%s, new_rdn=%s and exception: %s", rdn, attr_dict,
|
"error during LDAP update operation with: rdn='%s', "
|
||||||
new_rdn, e)
|
"attr_dict=%s, new_rdn=%s and exception: %s"
|
||||||
raise MoulinetteError('ldap_operation_error')
|
% (rdn, attr_dict, new_rdn, e),
|
||||||
|
raw_msg=True
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue