| Current Path : /var/www/html/mmishra/iws8/html/iport/ |
| Current File : /var/www/html/mmishra/iws8/html/iport/changepwd.inc |
<h3 align='left'>Change Password</h3>
<center>
<table width='30%' border='1' style="border-collapse:collapse">
<tr><th colspan='2'> For user [ <?php echo $user; ?> ]</th></tr>
<tr><th>Old password</th><td><input type='password' name='passwd0' size='20'></td></tr>
<tr><th>New password</th><td><input type='password' name='passwd1' size='20'></td></tr>
<tr><th>Confirm again</th><td><input type='password' name='passwd2' size='20'></td></tr>
<tr><th colspan='2'><input type='submit' name='submit' value='CHANGE'></th></tr>
</table>
<h3>
<?php
$pwd0 = $_POST["passwd0"];
$pwd1 = $_POST["passwd1"];
$pwd2 = $_POST["passwd2"];
if ($pwd1 && ($pwd1 == $pwd2)) {
//$ds = ldap_connect("172.31.1.42");
$ds = ldap_connect("ldaps://172.31.1.41:636");
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$q = ldap_search($ds, "dc=iiita,dc=ac,dc=in", "(&(uid=$user)(objectclass=posixAccount))");
$info = ldap_get_entries($ds, $q);
$dn = $info[0]["dn"];
$pwd = "{SHA}" . base64_encode(pack("H*", sha1($pwd1)));
$info1["userPassword"] = "$pwd";
//$pwd0 = "{SHA}" . base64_encode(pack("H*", sha1($pwd0)));
if ($info["count"] > 0) {
ldap_bind($ds, "cn=Manager,dc=iiita,dc=ac,dc=in","\$dollfinn");
//if (ldap_bind($ds, $dn, $pwd0) && ldap_modify($ds, $dn, $info1)) {
if (ldap_modify($ds, $dn, $info1)) {
mysql_query("update webusers set pwd='$pwd' where userid='$user'");
echo "Password changed";
} else {
echo "Bind error";
}
}
ldap_close($ds);
} else if ($pwd1) {
echo "Password mismatch";
}
?>
</h3>
</center>