1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
<?php session_start(); ?>
<?php
$ldap_con = ldap_connect("localhost:389") or die("Could not connect to server. Error is " . ldap_error($ldap_con));
$root_dn="cn=Manager,dc=universite,dc=com";
$root_pw="azerty";
$ldap_bd = ldap_bind($ldap_con, $root_dn, $root_pw) or die("Could not bind to server. Error is " .ldap_error($ldap_con));
$personnel_base = "ou=etudiant,dc=universite,dc=com";
$result = ldap_search($ldap_con, $personnel_base, "(uid=*)") or die ("Error in query");
$data = ldap_get_entries($ldap_con, $result);
//traitement de la suppressioin au debut du scrtipt : réaffichera ceux qui restent après la suppression
//il faut supprime si le bouton a été cliqué
if(isset($_POST['supprimer']))
{
//récupération des checkbox cochées dans un array ---------------> nomme table_array
$supp=""; //non effecte donc cela donne des erreur alors-----Undefined index: table_array in----
// $supp="0"; // Aucun enregistrement n'a 0 pour ID ;)
if(isset($_POST['table_array']))
{
$Clef=$_POST['table_array'];
foreach($Clef as $selectValue)
{
if($supp!=""){$supp.=",";}
$supp.=$selectValue;
}
}
$tab = explode(",", $supp);
for($i = 0; $i < sizeof($tab); $i++)
{
$ds=ldap_connect("localhost:389"); // Doit être un serveur LDAP valide!
$root="cn=Manager,dc=universite,dc=com";
$pass="azerty";
if ($ds) {
$r=ldap_bind($ds,$root,$pass);
$dn = "cn=$SN $Givenname,ou=etudiant,dc=universite,dc=com";
ldap_delete($ds,$dn);
}
}
}
?>
<html>
<body bgcolor="black" text="white" >
<center>
<font size="8" color="blue"><B><I> Suppression d'une entrée </I></B> </font> </center>
<form method="post" id="FormServiceClient" name="FormServiceClient" action="test.php" enctype="multipart/form-data">
<table width="60%" border="2" ><tr bgcolor="red"><td align="center" >
ObjectClass</td> <td align="center" >
Givenname</td> <td align="center" >
SN</td> <td align="center" > CN</td> <td align="center" >
UserName</td> <td align="center" > UserPassword</td> <td align="center" > UidNumber</td> <td align="center" > HomeDirectory</td>
<td align="center" >GidNumber</td> </tr> ;
<?
for ($i=0; $i<$data["count"];$i++) { ?>
<tr>
<?
for ($j=0;$j<=$data[$i]["count"];$j++){ ?>
<td> <? echo $data[$i][$data[$i][$j]][0];?> </td>
<? } ?> <td><input type='checkbox' name='table_array[]' value='$UidNumber'></td> </tr>
<?}?>
<? ldap_close($ldap_con); ?>
</table>
<BR><BR><BR>
<center>
<input type="submit" value="supprimer" name="supprimer" ></center>
</body>
</html> |
Partager