47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?php
|
|
session_start();
|
|
|
|
// Check if user is logged in and is admin
|
|
if (!isset($_SESSION["login"]) || !$_SESSION["is_admin"]) {
|
|
header("Location: ../index.php");
|
|
exit;
|
|
}
|
|
|
|
require_once __DIR__ . '/../controllers/controllerAdmin.php';
|
|
|
|
echo "<h2>Gestion des utilisateurs</h2>";
|
|
|
|
// Display users table
|
|
echo "<table border='1'>
|
|
<tr>
|
|
<th>Nom</th>
|
|
<th>Email</th>
|
|
<th>OU</th>
|
|
<th>Actions</th>
|
|
</tr>";
|
|
|
|
$users = listAllUsers();
|
|
foreach ($users as $user) {
|
|
$name = htmlspecialchars($user['cn'][0]);
|
|
$email = htmlspecialchars($user['mail'][0] ?? 'N/A');
|
|
$ou = htmlspecialchars($user['ou']);
|
|
$dn = htmlspecialchars($user['distinguishedname'][0]);
|
|
|
|
echo "<tr>
|
|
<td>$name</td>
|
|
<td>$email</td>
|
|
<td>$ou</td>
|
|
<td>
|
|
<form method='post' action='edit_user.php' style='display:inline;'>
|
|
<input type='hidden' name='user_dn' value='$dn'>
|
|
<input type='submit' value='Modifier'>
|
|
</form>
|
|
<form method='post' action='delete_user.php' style='display:inline;' onsubmit='return confirm(\"Confirmer la suppression ?\");'>
|
|
<input type='hidden' name='user_dn' value='$dn'>
|
|
<input type='submit' value='Supprimer'>
|
|
</form>
|
|
</td>
|
|
</tr>";
|
|
}
|
|
echo "</table>";
|