diff --git a/locales/en.json b/locales/en.json index 5c55d14c..97ff034f 100644 --- a/locales/en.json +++ b/locales/en.json @@ -19,7 +19,6 @@ "invalid_token": "Invalid token - please authenticate", "invalid_usage": "Invalid usage, pass --help to see help", "ldap_attribute_already_exists": "Attribute '{attribute}' already exists with value '{value}'", - "ldap_operation_error": "An error occurred during LDAP '{action}' operation", "ldap_server_down": "Unable to reach LDAP server", "logged_in": "Logged in", "logged_out": "Logged out", diff --git a/moulinette/authenticators/ldap.py b/moulinette/authenticators/ldap.py index 312b75f0..1e990c0f 100644 --- a/moulinette/authenticators/ldap.py +++ b/moulinette/authenticators/ldap.py @@ -148,15 +148,12 @@ class Authenticator(BaseAuthenticator): try: result = self.con.search_s(base, ldap.SCOPE_SUBTREE, filter, attrs) except Exception as e: - logger.exception( + raise MoulinetteError( "error during LDAP search operation with: base='%s', " - "filter='%s', attrs=%s and exception %s", - base, - filter, - attrs, - e, + "filter='%s', attrs=%s and exception %s" + % (base, filter, attrs, e), + raw_msg=True ) - raise MoulinetteError("ldap_operation_error", action="search") result_list = [] if not attrs or "dn" not in attrs: @@ -185,14 +182,12 @@ class Authenticator(BaseAuthenticator): try: self.con.add_s(dn, ldif) except Exception as e: - logger.exception( + raise MoulinetteError( "error during LDAP add operation with: rdn='%s', " - "attr_dict=%s and exception %s", - rdn, - attr_dict, - e, + "attr_dict=%s and exception %s" + % (rdn, attr_dict, e), + raw_msg=True ) - raise MoulinetteError("ldap_operation_error", action="add") else: return True @@ -211,12 +206,11 @@ class Authenticator(BaseAuthenticator): try: self.con.delete_s(dn) except Exception as e: - logger.exception( - "error during LDAP delete operation with: rdn='%s' and exception %s", - rdn, - e, + raise MoulinetteError( + "error during LDAP delete operation with: rdn='%s' and exception %s" + % (rdn, e), + raw_msg=True ) - raise MoulinetteError("ldap_operation_error", action="remove") else: return True @@ -249,15 +243,12 @@ class Authenticator(BaseAuthenticator): self.con.modify_ext_s(dn, ldif) except Exception as e: - logger.exception( + raise MoulinetteError( "error during LDAP update operation with: rdn='%s', " - "attr_dict=%s, new_rdn=%s and exception: %s", - rdn, - attr_dict, - new_rdn, - e, + "attr_dict=%s, new_rdn=%s and exception: %s" + % (rdn, attr_dict, new_rdn, e), + raw_msg=True ) - raise MoulinetteError("ldap_operation_error", action="update") else: return True