Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/indem/scripts/php/
Upload File :
Current File : /var/www/html/mmishra/indem/scripts/php/set_initials.php

<?php

$ds = ldap_connect("ldap.iiita.ac.in");
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);

/*
echo "Enter Campus [iiita/rgiit]: ";
$campus = fgets(STDIN);
$campus = str_replace("\n","",$campus);

echo "Enter Course [btech/mtech/mba/ms]: ";
$course = fgets(STDIN);
$course = str_replace("\n","",$course);

echo "Enter Specialization [it/ece/is/se/bi/ro/mi/hci/wcc/clis]: ";
$spec = fgets(STDIN);
$spec = str_replace("\n","",$spec);

echo "Enter Batch Year [yyyy]: ";
$batch = fgets(STDIN);
$batch = str_replace("\n","",$batch);

echo "Proceed? [y/n]: ";
$yn = fgets(STDIN);
$yn = str_replace("\n","",$yn);

if ($yn == 'n') exit("Aborted.");

if ($campus == "iiita") $category = "student";
else $category = "rgiit";
*/
if ($ds){
  	$ou = "ou=employee,dc=iiita,dc=ac,dc=in";
  	$sr = ldap_search($ds, "$ou", "(&(uid=*)(objectclass=posixaccount))");
  	$info = ldap_get_entries($ds, $sr);
  	for ($i=0; $i < $info["count"]; $i++) {
    		$uid = $info[$i]["uid"][0];
    		$dn = $info[$i]["dn"];
    		$email = $info[$i]["mail"][0];
    		$initials = $info[$i]["initials"][0];
    		echo $i .'--'. $uid .'--'. $initials . "\n";

    		if ($uid){
      			$db = ldap_bind($ds, "cn=Manager,dc=iiita,dc=ac,dc=in", "\$dollfinn");
      			//$dn = "uid=$uid,$ou";
 
      			//=========attributes to be removed
      			$info1["displayname"] = array();
      			@ldap_mod_del($ds, $dn, $info1);
      			
			//=========attributes to be modified
      			//$info2["initials"] = $title;
      			//@ldap_modify($ds, $dn, $info2);

      			echo $i .'--'. $dn . "\n";
    		}
 
 	}
}
ldap_close($ds);


?>