From cd33a6cc51a7f7283f101470d339d31643bc5aa3 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Wed, 25 Jan 2012 19:19:02 +0100 Subject: [PATCH] Reconnect to the LDAP server when the connexion is lost (fixes #656) --- radicale/acl/LDAP.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/radicale/acl/LDAP.py b/radicale/acl/LDAP.py index 32d0319..d6934ee 100644 --- a/radicale/acl/LDAP.py +++ b/radicale/acl/LDAP.py @@ -39,10 +39,18 @@ SCOPE = getattr(ldap, "SCOPE_%s" % config.get("acl", "ldap_scope").upper()) def has_right(owner, user, password): """Check if ``user``/``password`` couple is valid.""" + global CONNEXION + if not user or (owner not in acl.PRIVATE_USERS and user != owner): # No user given, or owner is not private and is not user, forbidden return False + try: + CONNEXION.whoami_s() + except: + log.LOGGER.debug("Reconnecting the LDAP server") + CONNEXION = ldap.initialize(config.get("acl", "ldap_url")) + if BINDDN and PASSWORD: log.LOGGER.debug("Initial LDAP bind as %s" % BINDDN) CONNEXION.simple_bind_s(BINDDN, PASSWORD)