44 lines
977 B
PHP
44 lines
977 B
PHP
<?php
|
|
require_once __DIR__ . '/../models/LDAPAuth.php';
|
|
|
|
function listAllOU()
|
|
{
|
|
$ldapAuth = new LDAPAuth();
|
|
return $ldapAuth->listAllOU();
|
|
}
|
|
|
|
function listAllUsers()
|
|
{
|
|
$ldapAuth = new LDAPAuth();
|
|
return $ldapAuth->listAllUsers();
|
|
}
|
|
|
|
function getUserOU($username)
|
|
{
|
|
$ldapAuth = new LDAPAuth();
|
|
return $ldapAuth->getUserOU($username);
|
|
}
|
|
|
|
function listUsers()
|
|
{
|
|
if (!isset($_SESSION["is_admin"])) {
|
|
die("Accès non autorisé");
|
|
}
|
|
|
|
$ldapAuth = new LDAPAuth();
|
|
|
|
if (isset($_GET['ou'])) {
|
|
// Lister les utilisateurs d'une OU spécifique
|
|
$ou_dn = urldecode($_GET['ou']);
|
|
if (!in_array($ou_dn, $_SESSION['admin_ous'])) {
|
|
die("Vous n'avez pas les droits sur cette OU");
|
|
}
|
|
$users = $ldapAuth->listUsersByOU($ou_dn);
|
|
} else {
|
|
// Lister tous les utilisateurs des OUs administrées
|
|
$users = $ldapAuth->listUsersByOUs($_SESSION['admin_ous']);
|
|
}
|
|
|
|
return $users;
|
|
}
|