]> git.ipfire.org Git - ipfire.org.git/commitdiff
accounts: Try to automatically re-connect to the LDAP server
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 7 May 2019 09:43:57 +0000 (10:43 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 7 May 2019 09:43:57 +0000 (10:43 +0100)
When the connection is lost, we should try to re-connect.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/accounts.py

index 2098a33c4eb95a4428f86a895c70b0043afe62eb..4e6d892ac2ee2bb81f77d74f8ef07a931c29a9cf 100644 (file)
@@ -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: