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