#!/usr/bin/perl

do "ldap_users.pl";
do "users.pl";
&connect ();
&ReadParse();

$sort_on = $in{sort_on};
$dn = $in{dn};

if ($in{set}) {
    &set_passwd ($dn, $in{passwd}, $in{hash});
    &redirect ("edit_user.cgi?sort_on=$sort_on&dn=$dn");
    exit (0);
}

# display current user data

$entry = &get_user_attr ($dn);
&user_from_entry ($entry);

&header ("Set Password for LDAP User", "");
print "<HR noshade size=2>\n";

print "<FORM method=\"post\" action=\"set_passwd.cgi\">\n";
print "<INPUT type=\"hidden\" name=\"dn\" value=\"$dn\">\n";
print "<INPUT type=\"hidden\" name=\"sort_on\" value=\"$sort_on\">\n";
print "<TABLE cellpadding=0 border $cb>\n";
print "<TR><TD>\n";
print "<TABLE cellspacing=0 cellpadding=2 border=0 $cb>\n";

print "<TR><TD colspan=2 $tb>Setting password for user <B>'$cn'</B> ($uid)\n";
print "<TR><TD>New password\n";
print "</TD><TD>";
print "<INPUT name=\"passwd\" size=12>\n";
print "</TD></TR>";
print "<TR><TD>Password type\n";
print "</TD><TD>";
print "<INPUT type=\"radio\" name=\"hash\" value=\"md5\">MD5\n";
print "<INPUT type=\"radio\" name=\"hash\" value=\"crypt\" checked>Unix crypt\n";
print "<INPUT type=\"radio\" name=\"hash\" value=\"nome\">Do not hash (plain
 text)\n";
print "</TD></TR>";

print "</TD></TR>\n";
print "</TABLE>\n";
print "</TD></TR>\n";
print "</TABLE>\n";
print "<BR><INPUT type=\"submit\" name=\"set\" value=\" Set password \">\n";

print "<P>\n";
&footer ("edit_user.cgi?sort_on=$sort_on&dn=$dn", "Edit LDAP User");
do "footer.pl";

