| Current Path : /var/www/html/mmishra/iws8/html/indem/ |
| Current File : /var/www/html/mmishra/iws8/html/indem/createaccount.inc |
#!/usr/bin/php -q
<?
//Generate salted crypt passwords
function ldap_crypt_passwd($password,$salt,$stype) {
if ($stype=="MD5") return "{CRYPT}" . crypt($password); //, $salt);
//if ($stype=="MD5") return crypt($password,substr($salt,0,12)); //MD5 uses 12 chr salt
}
$file = "mba.txt";
$fp = @fopen($file,"r");
if(!$fp)
exit("file not found\n");
$contents = fread($fp,filesize($file));
$batch = "mba07";
$description = "Student of MBA 2007-2009";
$gidNumber = "3006";
$homeDirectory = "mba07";
$accountStatus = "active";
$mobile = "94";
$mailstore = "/mail/2007/pg/mba/it";
$size = "262144000";
$line=explode("\n",$contents);
for($i=0;$i<count($line)-1;$i++) {
$fullname = ""; $roll = "";
list($roll,$fullname) = split(",",$line[$i]);
// $fullname = trim($fullname);
//Due to unknown pattern of data
//$fullname = substr($fullname,0,strlen($fullname)-1);
$gecos = trim($fullname); //substr($fullname,3,strlen($fullname));
//generate uid from gecos
$names = explode(" ",$gecos);
$uid = "";
//for($j=0;$j<count($names)-1;$j++) $uid.=substr($names[$j],0,1);
$lastname = trim($names[count($names)-1]);
$firstname = $names[0];
$uid = trim($uid);
// $lastname = trim($lastname,'|');
$uid .= $roll; //$lastname.".".$batch;
//$uid = strtolower($uid);
//Generate ldif file
$cn = str_replace(" ","-",$gecos)."-".$roll;
//echo "names[0] $names[1]\n";
//$ou = "MBA 2006-2008";
$pass = "{CRYPT}$1\$TGpghNx0\$jEh4MeB3UFsRnWqT21xF91";
$text = "dn: uid=$roll,ou=2007,ou=MBA,ou=Students,dc=iiita,dc=ac,dc=in \n";
$text .= "objectClass: top\n";
$text .= "objectClass: person\n";
$text .= "objectClass: posixAccount\n";
$text .= "objectClass: shadowAccount\n";
$text .= "objectClass: inetOrgPerson\n";
$text .= "objectClass: organizationalPerson\n";
$text .= "objectClass: ibm-auxAccount\n";
$text .= "objectClass: qmailUser\n";
$text .= "businessCategory: everyone\n";
$text .= "businessCategory: students\n";
$text .= "businessCategory: mba\n";
$text .= "businessCategory: 2007\n";
$text .= "uid: $roll\n";
$text .= "accountStatus: $accountStatus\n";
$text .= "description: $description\n";
$text .= "gecos: $gecos\n";
$text .= "cn: $cn\n";
//$text .= "ou: $ou\n";
$text .= "mail: $uid@iiita.ac.in\n";
$text .= "mailHost: mail.iiita.ac.in\n";
$text .= "mailMessageStore: $mailstore/$uid\n";
$text .= "mailQuotaSize: $size\n";
$text .= "gidNumber: $gidNumber\n";
$text .= "givenName: $firstname\n";
$text .= "homeDirectory: /home/$homeDirectory/$uid\n";
$text .= "host: *\n";
$text .= "labeledURI: http://profile.iiita.ac.in/$uid\n";
$text .= "loginShell: /bin/bash\n";
//$text .= "o: IIIT Allahabad\n";
$text .= "sn: $lastname\n";
$text .= "mobile: $mobile\n";
$text .= "uidNumber: 999999\n";
$text .= "userPassword: $pass\n\n";
$text .= "\n";
echo $text;
// echo "\n";
$uid1[$i] = $uid;
}
//asort($uid1);
//for($i=0;$i<count($line)-1;$i++)
//{
// echo $uid1[$i];
// echo "\n";
//}
?>