diff --git a/LibreNMS/Authentication/LdapAuthorizer.php b/LibreNMS/Authentication/LdapAuthorizer.php index 7071335104..308dca018a 100644 --- a/LibreNMS/Authentication/LdapAuthorizer.php +++ b/LibreNMS/Authentication/LdapAuthorizer.php @@ -9,7 +9,6 @@ use LibreNMS\Exceptions\LdapMissingException; class LdapAuthorizer extends AuthorizerBase { protected $ldap_connection; - private $userloginname = ""; public function authenticate($credentials) { @@ -17,7 +16,6 @@ class LdapAuthorizer extends AuthorizerBase if (!empty($credentials['username'])) { $username = $credentials['username']; - $this->userloginname = $username; if (!empty($credentials['password']) && ldap_bind($connection, $this->getFullDn($username), $credentials['password'])) { $ldap_groups = $this->getGroupList(); if (empty($ldap_groups)) { @@ -200,22 +198,10 @@ class LdapAuthorizer extends AuthorizerBase public function getUser($user_id) { - $connection = $this->getLdapConnection(); - - $filter = '(' . Config::get('auth_ldap_prefix') . '*)'; - if (Config::get('auth_ldap_userlist_filter') != null) { - $filter = '(' . Config::get('auth_ldap_userlist_filter') . ')'; - } - - $search = ldap_search($connection, $this->getFullDn($this->userloginname), $filter); - $entries = ldap_get_entries($connection, $search); - foreach ($entries as $entry) { - $user = $this->ldapToUser($entry); - if ((int)$user['user_id'] !== (int)$user_id) { - continue; + foreach ($this->getUserlist() as $user) { + if ((int)$user['user_id'] === (int)$user_id) { + return $user; } - - return $user; } return 0; }