| Current Path : /var/www/html/mmishra/mm/scripts/ |
| Current File : /var/www/html/mmishra/mm/scripts/mailinglist_remove.php |
<?php
$ds = ldap_connect("ldap.iiita.ac.in");
//fwrite(STDOUT, "Please enter mailing list name\n");
// Read the input
echo "Enter List Name: ";
$listname = fgets(STDIN);
$listname = str_replace("\n","",$listname);//to remove \n character
echo "Proceed with Creation? [y/n]: ";
$confirm = fgets(STDIN);
$confirm = str_replace("\n","",$confirm);//to remove \n character
if ($confirm == "y"){
echo $listname . " List deletion in progress...\n";
$command = "rm -r /mail/lists/$listname";
$output = shell_exec($command);
echo "Mailstore removed... $command >> $output\n";
}else{
exit("Aborted.");
}
//create ldap account
$ou = "ou=mailinglists,dc=iiita,dc=ac,dc=in";
if ($ds){
// bind with appropriate dn to give update access
$r = ldap_bind($ds, "cn=Manager,dc=iiita,dc=ac,dc=in", "aksr2it");
$dn = "uid=$listname,$ou";
$r = ldap_delete($ds, $dn);
if ($r) echo $dn . " -- " . $listname . "@lists.iiita.ac.in successfully deleted.\n";
else echo $dn . " -- " . $listname . "@lists.iiita.ac.in could not be deleted.\n";
}
ldap_close($ds);
?>