summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGES.txt6
-rw-r--r--LDAPLoginAdapter.py24
2 files changed, 25 insertions, 5 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index f5e640e..d51e11b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -6,7 +6,11 @@ CHANGES.txt for the LDAPLoginAdapter
Bugs fixed:
- * _lookupuser had an exeption handler that would try and use a
+ * Completely revamped the exception handling in authenticate
+ so that there will always be a (hopefully) helpful output
+ in the log
+
+ * authenticate had an exeption handler that would try and use a
variable left uninitialized when the exception was thrown.
LDAPLoginAdapter 1.2beta3
diff --git a/LDAPLoginAdapter.py b/LDAPLoginAdapter.py
index 24a6c17..18c477e 100644
--- a/LDAPLoginAdapter.py
+++ b/LDAPLoginAdapter.py
@@ -721,14 +721,30 @@ class LDAPLoginAdapter(BasicUserFolder, ObjectManager, Implicit, Base):
self.verbose > 8 and self._logit(9,
'Unknown user %s not validated' % name)
return None
- except ldap.INVALID_CREDENTIALS:
+ except ldap.LDAPError, e:
+ infotuple = getattr(e, 'args', ())
+ if infotuple:
+ errordict = infotuple[0]
+ msg = 'Error Type: %s, Server Message: %s' % (
+ errordict.get('desc', 'Not Available'),
+ errordict.get('info', 'Not Available'))
+ else:
+ msg = 'Unknown LDAP Error'
+
+ self.verbose > 0 and self._logit(1,
+ 'Exception in _lookupuser looking up %s: %s' % (name, msg))
+
return None
- except:
+
+ except Exception, e:
+ msg = getattr(e, 'args', ('Unknown Error',))[0]
+
self.verbose > 0 and self._logit(1,
- 'Exception in _lookupuser looking up %s' % (name))
+ 'Exception in _lookupuser looking up %s: %s' % (name, msg))
+
return None
- if uroles == None:
+ if uroles is None:
self.verbose > 8 and self._logit(9,
'%s returned no roles' % name)
return None