| Current Path : /var/www/html/mmishra/indem/scripts/php/ |
| Current File : /var/www/html/mmishra/indem/scripts/php/tune_employee_account.php |
<?php
$ds = ldap_connect("ldap.iiita.ac.in");
echo "Enter Category [faculty/officer/techstaff/adminstaff/projectstaff]: ";
$category = fgets(STDIN);
$category = str_replace("\n","",$category);
echo "Proceed? [y/n]: ";
$yn = fgets(STDIN);
$yn = str_replace("\n","",$yn);
if ($yn == 'n') exit("Aborted.");
$ou = "ou=$category,ou=employee,dc=iiita,dc=ac,dc=in";
if ($ds){
// bind with appropriate dn to give update access
$r = ldap_bind($ds);
$sr = ldap_search($ds, "$ou", "uid=*");
$info = ldap_get_entries($ds, $sr);
for ($i=0; $i < $info["count"]; $i++) {
$uid = $info[$i]["uid"][0];
$cn = $info[$i]["cn"][0];
$gecos = $info[$i]["gecos"][0];
$email = $info[$i]["mail"][0];
if ($uid){
$db = ldap_bind($ds, "cn=Manager,dc=iiita,dc=ac,dc=in", "aksr2it");
$dn = "uid=$uid,$ou";
//=========attributes to be removed
$info11["ou"] = array();
$r1 = ldap_mod_del($ds, $dn, $info11);
$info12["o"] = array();
$r1 = ldap_mod_del($ds, $dn, $info12);
$info13["businesscategory"] = array();
$r1 = ldap_mod_del($ds, $dn, $info13);
$info14["title"] = array();
$r1 = ldap_mod_del($ds, $dn, $info14);
$info15["host"] = array();
$r1 = ldap_mod_del($ds, $dn, $info15);
//=========attributes to be added
$info2["businesscategory"][0] = "everyone";
if ($category == "techstaff" || $category == "adminstaff" || $category == "projectstaff"){
$info2["businesscategory"][1] = "staff";
$info2["mailquotasize"] = "524288000";
}else{
$info2["businesscategory"][1] = "$category";
$info2["mailquotasize"] = "1048576000";
}
//$info2["description"] = strtoupper($category);
$info2["mail"] = $uid . "@iiita.ac.in";
$info2["mailmessagestore"] = "/staff/" . $uid;
$info2["mobile"] = "9450945094";
$info2["labeleduri"] = "http://profile.iiita.ac.in/" . $uid;
$info2["homedirectory"] = "/srv/www/profiles/" . $uid;
$info2["host"] = "*";
if ($gecos == "") $info2["gecos"] = $cn;
$info2["loginshell"] = "/bin/bash";
$r2 = ldap_modify($ds, $dn, $info2);
echo $dn . " -- " . $email . "\n";
}
}
}
ldap_close($ds);
?>