From 81f708d4dbec9f4ec843384910db3186acaf7f25 Mon Sep 17 00:00:00 2001 From: Dave Hall Date: Sun, 2 Jul 2023 10:17:58 +0100 Subject: [PATCH] Fixing has_user --- django_python3_ldap/ldap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_python3_ldap/ldap.py b/django_python3_ldap/ldap.py index d3d6ccc..922e0cd 100644 --- a/django_python3_ldap/ldap.py +++ b/django_python3_ldap/ldap.py @@ -137,7 +137,7 @@ def has_user(self, **kwargs): get_operational_attributes=True, size_limit=1, ) - return True if self._connection.response[0].get("attributes") else False + return bool(len(self._connection.response) > 0 and self._connection.response[0].get("attributes")) @contextmanager