mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
[enh] Catch error when LDAP server is down
This commit is contained in:
parent
dcdc4cff8e
commit
c781d10b54
3 changed files with 10 additions and 6 deletions
|
@ -10,7 +10,8 @@
|
||||||
|
|
||||||
"unable_authenticate" : "Unable to authenticate",
|
"unable_authenticate" : "Unable to authenticate",
|
||||||
"unable_retrieve_session" : "Unable to retrieve the session",
|
"unable_retrieve_session" : "Unable to retrieve the session",
|
||||||
"error_ldap_operation" : "An error occured during LDAP operation",
|
"ldap_server_down" : "Unable to reach LDAP server",
|
||||||
|
"ldap_operation_error" : "An error occured during LDAP operation",
|
||||||
|
|
||||||
"password" : "Password",
|
"password" : "Password",
|
||||||
"invalid_password" : "Invalid password",
|
"invalid_password" : "Invalid password",
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
|
|
||||||
"unable_authenticate" : "Impossible de vous authentifier",
|
"unable_authenticate" : "Impossible de vous authentifier",
|
||||||
"unable_retrieve_session" : "Impossible de récupérer la session",
|
"unable_retrieve_session" : "Impossible de récupérer la session",
|
||||||
"error_ldap_operation" : "Une erreur est survenue lors de l'opération LDAP",
|
"ldap_server_down" : "Impossible d'atteindre le serveur LDAP",
|
||||||
|
"ldap_operation_error" : "Une erreur est survenue lors de l'opération LDAP",
|
||||||
|
|
||||||
"password" : "Mot de passe",
|
"password" : "Mot de passe",
|
||||||
"invalid_password" : "Mot de passe incorrect",
|
"invalid_password" : "Mot de passe incorrect",
|
||||||
|
|
|
@ -66,6 +66,8 @@ class Authenticator(BaseAuthenticator):
|
||||||
con.simple_bind_s()
|
con.simple_bind_s()
|
||||||
except ldap.INVALID_CREDENTIALS:
|
except ldap.INVALID_CREDENTIALS:
|
||||||
raise MoulinetteError(errno.EACCES, m18n.g('invalid_password'))
|
raise MoulinetteError(errno.EACCES, m18n.g('invalid_password'))
|
||||||
|
except ldap.SERVER_DOWN:
|
||||||
|
raise MoulinetteError(169, m18n.g('ldap_server_down'))
|
||||||
else:
|
else:
|
||||||
self.con = con
|
self.con = con
|
||||||
|
|
||||||
|
@ -94,7 +96,7 @@ 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:
|
||||||
raise MoulinetteError(169, m18n.g('error_ldap_operation'))
|
raise MoulinetteError(169, m18n.g('ldap_operation_error'))
|
||||||
|
|
||||||
result_list = []
|
result_list = []
|
||||||
if not attrs or 'dn' not in attrs:
|
if not attrs or 'dn' not in attrs:
|
||||||
|
@ -123,7 +125,7 @@ class Authenticator(BaseAuthenticator):
|
||||||
try:
|
try:
|
||||||
self.con.add_s(dn, ldif)
|
self.con.add_s(dn, ldif)
|
||||||
except:
|
except:
|
||||||
raise MoulinetteError(169, m18n.g('error_ldap_operation'))
|
raise MoulinetteError(169, m18n.g('ldap_operation_error'))
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -142,7 +144,7 @@ class Authenticator(BaseAuthenticator):
|
||||||
try:
|
try:
|
||||||
self.con.delete_s(dn)
|
self.con.delete_s(dn)
|
||||||
except:
|
except:
|
||||||
raise MoulinetteError(169, m18n.g('error_ldap_operation'))
|
raise MoulinetteError(169, m18n.g('ldap_operation_error'))
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -170,7 +172,7 @@ class Authenticator(BaseAuthenticator):
|
||||||
|
|
||||||
self.con.modify_ext_s(dn, ldif)
|
self.con.modify_ext_s(dn, ldif)
|
||||||
except:
|
except:
|
||||||
raise MoulinetteError(169, m18n.g('error_ldap_operation'))
|
raise MoulinetteError(169, m18n.g('ldap_operation_error'))
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue