diff options
author | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2014-02-10 12:50:32 +0100 |
---|---|---|
committer | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2014-02-10 12:50:32 +0100 |
commit | 1dd622488bcea0ad61bfbee36cd3cd9cb1abc3ce (patch) | |
tree | 954b72a4110115d902288010c482f9183b6ad1a5 | |
parent | 1650125059262170e49c93eceea2194c1ad92d99 (diff) | |
download | pykolab-1dd622488bcea0ad61bfbee36cd3cd9cb1abc3ce.tar.gz |
If authentication fails specifically with a NO_SUCH_OBJECT error, re-attempt authentication after deleting the related entry from cache
-rw-r--r-- | pykolab/auth/ldap/__init__.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py index 8572fec..1ba0f3d 100644 --- a/pykolab/auth/ldap/__init__.py +++ b/pykolab/auth/ldap/__init__.py @@ -243,8 +243,21 @@ class LDAP(pykolab.base.Base): # Needs to be synchronous or succeeds and continues setting retval # to True!! self.ldap.simple_bind_s(entry_dn, login[1]) + auth_cache.set_entry(_filter, entry_dn) retval = True - except: + except ldap.NO_SUCH_OBJECT, errmsg: + log.debug(_("Error occured, there is no such object: %r") % (errmsg), level=8) + self.bind = False + try: + auth_cache.del_entry(_filter) + except: + log.error(_("Authentication cache failed to clear entry")) + pass + + return self.authenticate(login, realm) + + except Exception, errmsg: + log.debug(_("Exception occured: %r") %(errmsg)) try: log.debug( _("Failed to authenticate as user %s") % (login[0]), |