Merge pull request #18693 from FHenry/14_fix_ldap_limit

fix: User class fetch method if LDAP Search LIMIT must be after ORDER BY
This commit is contained in:
Laurent Destailleur 2021-09-13 17:04:43 +02:00 committed by GitHub
commit 7420e6ab9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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