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/tune_alumni_account.php

<?php

$ds = ldap_connect("ldap.iiita.ac.in");
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$dn = "ou=btech,ou=alumni,dc=iiita,dc=ac,dc=in";

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

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

if ($ds){
	//bind with appropriate dn to give update access
  	$sr = ldap_search($ds, $dn, "(&(uid=*)(objectClass=posixAccount))");
  	$info = ldap_get_entries($ds, $sr);
  	for ($i=0; $i < $info["count"]; $i++) {
    		$no++;
    		$uid = $info[$i]["uid"][0];
    		$cn = $info[$i]["cn"][0];
    		if ($info[$i]["gecos"][0] || $info[$i]["gecos"][0] == " "){
      			$gecos = $info[$i]["gecos"][0];
      			$gecos = strtoupper($gecos);
    		}else{
      			$gecos = strtoupper($cn);
    		}
    
    		if ($info[$i]["mail"][0]){
      			$mail = $info[$i]["mail"][0];
    		}else{
      			$mail = "$uid@iiita.ac.in";
    		}
    		$dn = $info[$i]["dn"];
    		$info1 = array();
    		$info2 = array();  
    		if ($uid){
      			ldap_bind($ds, "cn=Manager,dc=iiita,dc=ac,dc=in", "\$dollfinn");
 
      			//=========attributes to be removed
      			//$info1["businessCategory"] = array();
      			$info1["mailMessageStore"] = array();
      			$info1["mailQuotaSize"] = array();
      			@ldap_mod_del($ds, $dn, $info1);

      			//=========attributes to be added
      			$info2["businessCategory"][0] = "alumni";
      			$info2["deliveryProgramPath"][0] = "/opt/arithme/bin/maildrop.pl";
      			$info2["deliveryMode"][0] = "nolocals";
      			$info2["mailHost"][0] = "mail.iiita.ac.in";

      			echo $no . ". " . $dn . "\n";
      			foreach ($info2 as $inf2){
        			echo " -- " . $inf2[0] . "\n";
      			}
      			//@ldap_modify($ds, $dn, $info2);
    		}
  	}
}
ldap_close($ds);


?>