透過 ASP 修改 NT 使用者密碼

來源:互聯網
上載者:User


HTML 部分

當一個使用者登入你網站的安全區域, 你就可以利用 ServerVariables 集合中的 LOGIN_USER 來瞭解登入的使用者帳號, 當然記得要把允許匿名登入選項關閉, 現在就先來看 HTML 部分

<form action="changepwd.asp" method="post">
<!-- 為了不讓使用者自己輸入帳號所以使用隱藏 -->
<input type="hidden" name="UserName"
value="<%=Request.ServerVariables("LOGIN_USER")%>">
<br>輸入舊密碼 : <input name="OldPwd">
<br>輸入新密碼 : <input name="NewPwd1">
<br>確認新密碼 : <input name="NewPwd2">
<input type="submit" value=" 變更密碼 ">
</form>

程式碼

接下來是 ASP 的部分, 看看如何透過 ADSI 來修改 WIndows 2000 使用者帳號, 將下底的程式碼存成 changepwd.asp 檔名

<%
OldPwd = Request.Form("OldPwd")
NewPwd1 = Request.Form("NewPwd1")
NewPwd2 = Request.Form("NewPwd2")
UserName = Request.Form("UserName")

If NewPwd1 = NewPwd2 Then
Set oUser = GetObject("WinNT://ComputerName/" & UserName)
oUser.ChangePassword OldPwd, NewPwd1
oUser.SetInfo
Set oUser = Nothing
Else
Response.Write "請再確認你的密碼"
End If
%>




聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.