From c87b0e0a2822385c5978e3976943e70a7d923071 Mon Sep 17 00:00:00 2001 From: Robin Sonnabend <robin@fsmpi.rwth-aachen.de> Date: Tue, 13 Jun 2017 18:15:13 +0200 Subject: [PATCH] Do not show an error if the auth backend is unreachable --- auth.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/auth.py b/auth.py index fe838a7..a035052 100644 --- a/auth.py +++ b/auth.py @@ -58,8 +58,11 @@ class LdapManager: self.obsolete = obsolete def authenticate(self, username, password): - connection = ldap3.Connection(self.server, self.user_dn.format(username), password) - return connection.bind() + try: + connection = ldap3.Connection(self.server, self.user_dn.format(username), password) + return connection.bind() + except ldap3.core.exceptions.LDAPSocketOpenError: + return False def groups(self, username, password=None): connection = ldap3.Connection(self.server) @@ -100,7 +103,10 @@ class ADManager: return ldap3.Connection(self.server) def authenticate(self, username, password): - return self.prepare_connection(username, password).bind() + try: + return self.prepare_connection(username, password).bind() + except ldap3.core.exceptions.LDAPSocketOpenError: + return False def groups(self, username, password): connection = self.prepare_connection(username, password) -- GitLab