feat: add user details
This commit is contained in:
@@ -330,4 +330,33 @@ class LDAPAuth
|
||||
|
||||
return $users;
|
||||
}
|
||||
|
||||
public function getUserDetails($username)
|
||||
{
|
||||
$this->connect();
|
||||
$this->bindServiceAccount();
|
||||
|
||||
$filter = "(sAMAccountName=$username)";
|
||||
$attributes = ["*"]; // Récupère tous les attributs
|
||||
|
||||
$result = ldap_search($this->ad, "DC=epul3a,DC=local", $filter, $attributes);
|
||||
$entries = ldap_get_entries($this->ad, $result);
|
||||
|
||||
if ($entries['count'] > 0) {
|
||||
return $this->cleanLdapEntries($entries[0]);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
private function cleanLdapEntries($entry)
|
||||
{
|
||||
$clean = [];
|
||||
foreach ($entry as $key => $value) {
|
||||
if (!is_numeric($key) && is_array($value)) {
|
||||
$clean[$key] = $value[0];
|
||||
}
|
||||
}
|
||||
return $clean;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user