From d464922d717e4015f1ef308ef8f4421ae95b1672 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 13 Sep 2021 09:44:54 +0200 Subject: [PATCH] fix: LDAP Search LIMIT must be after ORDER BY --- htdocs/user/class/user.class.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 0a352210d41..55be42de5e0 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -455,8 +455,9 @@ class User extends CommonObject } } - if ($sid) { // permet une recherche du user par son SID ActiveDirectory ou Samba - $sql .= " AND (u.ldap_sid = '".$this->db->escape($sid)."' OR u.login = '".$this->db->escape($login)."') LIMIT 1"; + if ($sid) { + // permet une recherche du user par son SID ActiveDirectory ou Samba + $sql .= " AND (u.ldap_sid = '".$this->db->escape($sid)."' OR u.login = '".$this->db->escape($login)."')"; } elseif ($login) { $sql .= " AND u.login = '".$this->db->escape($login)."'"; } elseif ($email) { @@ -466,6 +467,11 @@ class User extends CommonObject } $sql .= " ORDER BY u.entity ASC"; // Avoid random result when there is 2 login in 2 different entities + if ($sid) { + // permet une recherche du user par son SID ActiveDirectory ou Samba + $sql .= ' '.$this->db->plimit(1); + } + $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result);