<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[gOxiA=苏繁=SuFan Blog]]></title> 
<link>https://sufan.maytide.net/index.php</link> 
<description><![CDATA[gOxiA,苏繁,sufan,Microsoft MVP]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[gOxiA=苏繁=SuFan Blog]]></copyright>
<item>
<link>https://sufan.maytide.net/read.php/833.htm</link>
<title><![CDATA[利用网页修改域登录密码]]></title> 
<author>gOxiA &lt;sufan_cn@msn.com&gt;</author>
<category><![CDATA[网络编程]]></category>
<pubDate>Fri, 17 Sep 2004 03:32:07 +0000</pubDate> 
<guid>https://sufan.maytide.net/read.php/833.htm</guid> 
<description>
<![CDATA[ 
	<p>你可以写一个ASP脚本来创建一个修改密码的网页。ASP可以让你完全访问活动目录接口（ADSI）,这样你就可以用ASP完成一系列的功能，向修改用户密码或者创建用户帐号。当你写这样一个脚本的时候，你必须考虑这样一个问题---哪些用户可以运行脚本，当脚本运行是你应该使用哪些权限。用来修改用户密码的基本的ADSI命令是：<div class="code">set usr = GetObject(&quot;LDAP://CN=John Savill,CN=Users,DC=savilltech,DC=com&quot;) usr.put &quot;userPassword&quot;, NewPassword</div>第一行分配了一个句炳给savilltech.com里面的用户john savill。第二行则把新密码放到用户的密码属性里面. 我写了一个比较短的asp脚本changepass.asp用来提示用户键入一个用户名和密码（记住你要把域名savilltech.com改成你自己的域名），下面是文件的代码：<div class="code">]&lt;%<br />strUserCN = request.form(&quot;cn&quot;)<br />strNewPassword = request.form(&quot;newpass&quot;)<br />strPassVerify = request.form(&quot;passverify&quot;)</p><p>if strUserCN=&quot;&quot; then<br />    response.write &quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;Change Password&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&quot;<br />    response.write &quot;&lt;center&gt;&lt;h1&gt;Web Password Reset&lt;/h1&gt;&lt;/center&gt;&quot;<br />    response.write &quot;&lt;hr&gt;</p><p>&lt;form method=post action=changepass.asp&gt;&lt;table&gt;&quot;<br />    response.write &quot;&lt;tr&gt;&lt;td&gt;CN: &lt;/td&gt;&lt;td&gt;&lt;input type=text name=cn&gt;&lt;/td&gt;&lt;tr&gt;&quot;<br />    response.write &quot;&lt;tr&gt;&lt;td&gt;New Password: &lt;/td&gt;&lt;td&gt;&lt;input type=password name=newpass&gt;&lt;/td&gt;&lt;/tr&gt;&quot;<br />    response.write &quot;&lt;tr&gt;&lt;td&gt;Verify Password: &lt;/td&gt;&lt;td&gt;&lt;input type=password name=passverify&gt;&lt;/td&gt;&lt;/tr&gt;&quot;<br />    response.write &quot;&lt;tr&gt;&lt;td colspan=2 align=center&gt;&lt;input type=submit value='Reset Password'&gt;&lt;/td&gt;&lt;/tr&gt;&quot;<br />    response.write &quot;&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;&quot;<br />    response.end<br />else</p><p>if strNewPassword = strPassVerify then</p><p>set usr = GetObject(&quot;<a href=\"ldap://CN\">LDAP://CN</a>=&quot; &amp; strUserCN &amp; &quot;,CN=Users,DC=savilltech,DC=com&quot;)</p><p>usr.put &quot;userPassword&quot;, strNewPassword</p><p>response.write &quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;Results&lt;/title&gt;&lt;/head&gt;&lt;center&gt;&lt;h1&gt;Update Results&lt;/h1&gt;&lt;/center&gt;&lt;hr&gt;</p><p>&quot;<br />response.write strUserCN &amp; &quot;: password was successfully updated&quot;<br />response.end</p><p>else</p><p>    response.write &quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;Error!&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&quot;<br />    response.write &quot;&lt;center&gt;&lt;h1&gt;An Error Has Occurred!&lt;/h1&gt;&lt;/center&gt;&quot;<br />    response.write &quot;&lt;hr&gt;</p><p>&quot;<br />    response.write &quot;The password and confirmation do not match. Please go back and try again.&quot;<br />    response.end</p><p>end if<br />end if<br />%&gt;<!--strUserCN = request.form(\"cn\")<br/>strNewPassword = request.form(\"newpass\")<br/>strPassVerify = request.form(\"passverify\")<br/><br/>if strUserCN=\"\" then<br/> &nbsp; &nbsp;response.write \"<html><head><title>Change Password</title></head><body>\"<br/> &nbsp; &nbsp;response.write \"<center><h1>Web Password Reset</h1></center>\"<br/> &nbsp; &nbsp;response.write \"<hr><br/><br/><form method=post action=changepass.asp><table>\"<br/> &nbsp; &nbsp;response.write \"<tr><td>CN: </td><td><input type=text name=cn></td><tr>\"<br/> &nbsp; &nbsp;response.write \"<tr><td>New Password: </td><td><input type=password name=newpass></td></tr>\"<br/> &nbsp; &nbsp;response.write \"<tr><td>Verify Password: </td><td><input type=password name=passverify></td></tr>\"<br/> &nbsp; &nbsp;response.write \"<tr><td colspan=2 align=center><input type=submit value='Reset Password'></td></tr>\"<br/> &nbsp; &nbsp;response.write \"</table></body></html>\"<br/> &nbsp; &nbsp;response.end<br/>else<br/><br/>if strNewPassword = strPassVerify then<br/><br/>set usr = GetObject(\"LDAP://CN=\" & strUserCN & \",CN=Users,DC=savilltech,DC=com\")<br/><br/>usr.put \"userPassword\", strNewPassword<br/><br/>response.write \"<html><head><title>Results</title></head><center><h1>Update Results</h1></center><hr><br/><br/>\"<br/>response.write strUserCN & \": password was successfully updated\"<br/>response.end<br/><br/>else<br/><br/> &nbsp; &nbsp;response.write \"<html><head><title>Error!</title></head><body>\"<br/> &nbsp; &nbsp;response.write \"<center><h1>An Error Has Occurred!</h1></center>\"<br/> &nbsp; &nbsp;response.write \"<hr><br/><br/>\"<br/> &nbsp; &nbsp;response.write \"The password and confirmation do not match. Please go back and try again.\"<br/> &nbsp; &nbsp;response.end<br/><br/>end if<br/>end if<br/>--></div>在WINDOWS SERVER 2003里面就提供了一个修改用户密码的网页英文原稿作者为John Savil </p>
]]>
</description>
</item>
</channel>
</rss>