From 2ef1c3670b5d6c7b0cc894e83347f20619631b11 Mon Sep 17 00:00:00 2001 From: Jellyfrog Date: Sun, 14 Aug 2022 16:14:12 +0200 Subject: [PATCH] Fix error when ldap_search returns false (#14199) --- LibreNMS/Authentication/ActiveDirectoryAuthorizer.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/LibreNMS/Authentication/ActiveDirectoryAuthorizer.php b/LibreNMS/Authentication/ActiveDirectoryAuthorizer.php index 35433b7cf0..a3f897af74 100644 --- a/LibreNMS/Authentication/ActiveDirectoryAuthorizer.php +++ b/LibreNMS/Authentication/ActiveDirectoryAuthorizer.php @@ -158,10 +158,13 @@ class ActiveDirectoryAuthorizer extends AuthorizerBase $this->userFilter($username), $attributes ); - $entries = ldap_get_entries($connection, $search); - if ($entries['count']) { - return $this->getUseridFromSid($this->sidFromLdap($entries[0]['objectsid'][0])); + if ($search !== false) { + $entries = ldap_get_entries($connection, $search); + + if ($entries !== false && $entries['count']) { + return $this->getUseridFromSid($this->sidFromLdap($entries[0]['objectsid'][0])); + } } return -1;