mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
[mod] remove catch-all try and provide real exception
This commit is contained in:
parent
2a3096a170
commit
455b7e49c0
1 changed files with 11 additions and 9 deletions
|
@ -62,7 +62,8 @@ class Authenticator(BaseAuthenticator):
|
||||||
try:
|
try:
|
||||||
# Retrieve identity
|
# Retrieve identity
|
||||||
who = self.con.whoami_s()
|
who = self.con.whoami_s()
|
||||||
except:
|
except Exception as e:
|
||||||
|
logger.warning("Error during ldap authentication process: %s", e)
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
if who[3:] == self.userdn:
|
if who[3:] == self.userdn:
|
||||||
|
@ -131,9 +132,9 @@ 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:
|
except Exception as e:
|
||||||
logger.exception("error during LDAP search operation with: base='%s', "
|
logger.exception("error during LDAP search operation with: base='%s', "
|
||||||
"filter='%s', attrs=%s", base, filter, attrs)
|
"filter='%s', attrs=%s and exception %s", base, filter, attrs, e)
|
||||||
raise MoulinetteError(169, m18n.g('ldap_operation_error'))
|
raise MoulinetteError(169, m18n.g('ldap_operation_error'))
|
||||||
|
|
||||||
result_list = []
|
result_list = []
|
||||||
|
@ -162,9 +163,9 @@ class Authenticator(BaseAuthenticator):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.con.add_s(dn, ldif)
|
self.con.add_s(dn, ldif)
|
||||||
except:
|
except Exception as e:
|
||||||
logger.exception("error during LDAP add operation with: rdn='%s', "
|
logger.exception("error during LDAP add operation with: rdn='%s', "
|
||||||
"attr_dict=%s", rdn, attr_dict)
|
"attr_dict=%s and exception %s", rdn, attr_dict, e)
|
||||||
raise MoulinetteError(169, m18n.g('ldap_operation_error'))
|
raise MoulinetteError(169, m18n.g('ldap_operation_error'))
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
@ -183,8 +184,8 @@ class Authenticator(BaseAuthenticator):
|
||||||
dn = rdn + ',' + self.basedn
|
dn = rdn + ',' + self.basedn
|
||||||
try:
|
try:
|
||||||
self.con.delete_s(dn)
|
self.con.delete_s(dn)
|
||||||
except:
|
except Exception as e:
|
||||||
logger.exception("error during LDAP delete operation with: rdn='%s'", rdn)
|
logger.exception("error during LDAP delete operation with: rdn='%s' and exception %s", rdn, e)
|
||||||
raise MoulinetteError(169, m18n.g('ldap_operation_error'))
|
raise MoulinetteError(169, m18n.g('ldap_operation_error'))
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
@ -212,9 +213,10 @@ class Authenticator(BaseAuthenticator):
|
||||||
dn = new_rdn + ',' + self.basedn
|
dn = new_rdn + ',' + self.basedn
|
||||||
|
|
||||||
self.con.modify_ext_s(dn, ldif)
|
self.con.modify_ext_s(dn, ldif)
|
||||||
except:
|
except Exception as e:
|
||||||
logger.exception("error during LDAP update operation with: rdn='%s', "
|
logger.exception("error during LDAP update operation with: rdn='%s', "
|
||||||
"attr_dict=%s, new_rdn=%s", rdn, attr_dict, new_rdn)
|
"attr_dict=%s, new_rdn=%s and exception: %s", rdn, attr_dict,
|
||||||
|
new_rdn, e)
|
||||||
raise MoulinetteError(169, m18n.g('ldap_operation_error'))
|
raise MoulinetteError(169, m18n.g('ldap_operation_error'))
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Add table
Reference in a new issue