Password change form:

helmetpastoralΛογισμικό & κατασκευή λογ/κού

13 Δεκ 2013 (πριν από 3 χρόνια και 8 μήνες)

93 εμφανίσεις

here is a working example script that will change a user’s password in a domain using perl. Very
basic and no error checking really, but this should give you an idea. As always, make sure this
page is using SSL.


Password change form:

Usern
ame



Old password



New password




Submit
Reset




---------------------------------
------------------

#!/usr/local/bin/perl


use CGI 'param', ':standard';

use Win32::NetAdmin;

print header;

print start_html;



if (param()){


$user = param('username');


$oldpassword = param('oldpass');


$newpassword = param('newpass');


if (Win32::Net
Admin::UserChangePassword("sgdomain", $user, $oldpassword,
$newpassword)){


print "<center><h1>The password for $user was changed</h1></center>";}


else {print "<center><h1>Could not change password. Old password may be
incorrect.</h1></center>";}



}else{


print <<EOF;



<h3 align="left">Password change form:</h3>

<form method="POST" action="chgpass.cgi">


<table border="1" width="35%">


<tr>


<td width="32%" align="right">


<p align="right">Username</td>


<td width="68%">


<p align="left"><input type="text" name="username" size="20"></td>


</tr>


<tr>


<td width="32%" align="right">


<p align="right">Old password</td>


<td width="68%">


<p align="left"><input type="password" name="oldpas
s" size="20"></td>


</tr>


<tr>


<td width="32%" align="right">


<p align="left">New password</td>


<td width="68%">


<p align="left"><input type="password" name="newpass" size="20"></td>


</tr>


<tr>


<td width="32
%" align="right">&nbsp;</td>


<td width="68%"><input type="submit" value="Submit" name="B1"><input type="reset"
value="Reset" name="B2"></td>


</tr>


</table>

</form>

EOF


;


}

print end_html;