From 443c87fa402ef6d086066412e4a047f54a45889f Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Wed, 29 Mar 2017 14:28:36 +0200 Subject: [PATCH] Do not try to bind if the user dn was not found with LDAP auth backend Then using the LDAP auth backend with ``bind`` method for password check, do not try to bind if the user dn was not found. This was causing the exception ``'NoneType' object has no attribute 'getitem'`` describe in #21 --- CHANGELOG.rst | 6 ++++++ cas_server/auth.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6e57a76..36025eb 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,6 +14,12 @@ Added ----- * Dutch translation +Fixed +----- +* Then using the LDAP auth backend with ``bind`` method for password check, do not try to bind + if the user dn was not found. This was causing the exception + ``'NoneType' object has no attribute 'getitem'`` describe in #21 + v0.8.0 - 2017-03-08 =================== diff --git a/cas_server/auth.py b/cas_server/auth.py index bcdce71..9a0893e 100644 --- a/cas_server/auth.py +++ b/cas_server/auth.py @@ -321,7 +321,7 @@ class LdapAuthUser(DBAuthUser): # pragma: no cover correct, ``False`` otherwise. :rtype: bool """ - if settings.CAS_LDAP_PASSWORD_CHECK == "bind": + if self.user and settings.CAS_LDAP_PASSWORD_CHECK == "bind": try: conn = ldap3.Connection( settings.CAS_LDAP_SERVER,