diff --git a/models/LDAPAuth.php b/models/LDAPAuth.php index 333e535..10ef257 100644 --- a/models/LDAPAuth.php +++ b/models/LDAPAuth.php @@ -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; + } } diff --git a/views/menu.php b/views/menu.php index 09f3e6a..9016c78 100644 --- a/views/menu.php +++ b/views/menu.php @@ -19,8 +19,8 @@ echo "Bienvenue " . $_SESSION["sAMAccountName"] . "!"; echo "

Menu

"; echo "