From 6c9a866360da4e9cdbfeeead51cea55064a37d90 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 7 May 2019 10:43:57 +0100 Subject: [PATCH] accounts: Try to automatically re-connect to the LDAP server When the connection is lost, we should try to re-connect. Signed-off-by: Michael Tremer --- src/backend/accounts.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/accounts.py b/src/backend/accounts.py index 2098a33c..4e6d892a 100644 --- a/src/backend/accounts.py +++ b/src/backend/accounts.py @@ -33,10 +33,13 @@ class Accounts(Object): def ldap(self): # Connect to LDAP server ldap_uri = self.settings.get("ldap_uri") - conn = ldap.initialize(ldap_uri) logging.debug("Connecting to LDAP server: %s" % ldap_uri) + # Connect to the LDAP server + conn = ldap.ldapobject.ReconnectLDAPObject(ldap_uri, + retry_max=10, retry_delay=3) + # Bind with username and password bind_dn = self.settings.get("ldap_bind_dn") if bind_dn: -- 2.47.3