feat: add user details

This commit is contained in:
Morph01
2025-02-04 14:51:10 -08:00
parent 9ed9dad583
commit 2baa69fe34
2 changed files with 45 additions and 6 deletions

View File

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