Revert "Fix LDAP slow login (#10760)" (#10855)

This reverts commit baab9596a0.
This commit is contained in:
louis-oui
2019-11-20 23:58:06 +01:00
committed by Tony Murray
parent e9e309c0e0
commit f19bbcab41

View File

@@ -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;
}