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

<?php

$ds = ldap_connect("ldap.iiita.ac.in");
if ($ds){
  echo "Creating globalAddressBook...\n";
  $fp = fopen("/mail/scripts/php/globalAddressBook", "w");
  // bind with appropriate dn to give update access
  $r = ldap_bind($ds);
  $ou = "ou=mailinglist,dc=iiita,dc=ac,dc=in";
  $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];
    $mail = $info[$i]["mail"][0];
    $desc = $info[$i]["description"][0];
    $sn = $info[$i]["sn"][0];

    fwrite($fp, "$uid|$cn||$mail|$desc\n");
  }
  fclose($fp);
}
ldap_close($ds);

$cmd = "scp -P 22022 /mail/scripts/php/globalAddressBook root@172.31.1.25:/var/lib/squirrelmail/";
$output = shell_exec($cmd);

echo "globalAddressBook created.\n";
?>