用ASP修改NT登陆密码
类别: ASP教程
<%
Sub ChangeUserPassword(Computer,UserName,oldPassword,newPassword)
Dim adsUser,foundErr,ErrMsg
On Error Resume Next
foundErr=False
ErrMsg=""
Set adsUser=GetObject("WinNT://"+Computer+"/"+UserName+",user")
If Err.Number<>0 Then
foundErr=True
ErrMsg="User not found!"
Err.Clear
Else
adsUser.ChangePassword oldPassword, newPassword
adsUser.SetInfo
If Err.Number<>0 Then
foundErr=True
ErrMsg=Now & ". Error Code: " & Hex(Err) & " - " & Err.Description & "
"
Err.Clear
End If
End If
If Not foundErr Then
objContext.SetComplete
Response.Write "<font class=""A2"" size=""2"" face=""Arial"">[B]Password changed successful!
[/B]
"
Response.Write "<input type=""button"" class=""A1"" name=""b2"" value="" Back ""
onclick=""window.location.replace(\'default.asp\');"">"
Response.Write "</font>"
Else
objContext.SetAbort
Response.Write "<font class=""A2"" size=""2"" face=""Arial"">[B]Wrong old password, back to
reinput![/B]
"&ErrMsg
Response.Write "<input type=""button"" class=""A1"" name=""b2"" value="" Back ""
onclick=""history.back();"">"
Response.Write "</font>"
End If
Set adsUser=Nothing
End Sub
response.write "NT的密码改为qian!"
Computer="yp"
UserName="sky"
oldPassword="dir"
newPassword="qian"
ChangeUserPassword Computer,UserName,oldPassword,newPassword
%>
Sub ChangeUserPassword(Computer,UserName,oldPassword,newPassword)
Dim adsUser,foundErr,ErrMsg
On Error Resume Next
foundErr=False
ErrMsg=""
Set adsUser=GetObject("WinNT://"+Computer+"/"+UserName+",user")
If Err.Number<>0 Then
foundErr=True
ErrMsg="User not found!"
Err.Clear
Else
adsUser.ChangePassword oldPassword, newPassword
adsUser.SetInfo
If Err.Number<>0 Then
foundErr=True
ErrMsg=Now & ". Error Code: " & Hex(Err) & " - " & Err.Description & "
"
Err.Clear
End If
End If
If Not foundErr Then
objContext.SetComplete
Response.Write "<font class=""A2"" size=""2"" face=""Arial"">[B]Password changed successful!
[/B]
"
Response.Write "<input type=""button"" class=""A1"" name=""b2"" value="" Back ""
onclick=""window.location.replace(\'default.asp\');"">"
Response.Write "</font>"
Else
objContext.SetAbort
Response.Write "<font class=""A2"" size=""2"" face=""Arial"">[B]Wrong old password, back to
reinput![/B]
"&ErrMsg
Response.Write "<input type=""button"" class=""A1"" name=""b2"" value="" Back ""
onclick=""history.back();"">"
Response.Write "</font>"
End If
Set adsUser=Nothing
End Sub
response.write "NT的密码改为qian!"
Computer="yp"
UserName="sky"
oldPassword="dir"
newPassword="qian"
ChangeUserPassword Computer,UserName,oldPassword,newPassword
%>
- 上一篇: 实例演练ASP+XML编程(1)
- 下一篇: ASP的函数详解(1)
-= 资 源 教 程 =-
文 章 搜 索