Change password from an ASP page. | |
---|---|
<%@ Language=VBScript%> <% Dim UserName, ResultHTML UserName = Request.ServerVariables("AUTH_USER") If Len(UserName) = 0 Then Response.Status = "401 acess denied" Response.Write "<Font color=red>You have to logon to change your password</Font><br>" Response.Write String(1024, " ")'why MS means that friendly errors are friendly??? Response.End Else Dim xServer Set xServer = CreateObject("UserManager.Server") Dim User, PasswordExpires Set User = GetUser(UserName) PasswordExpires = User.PasswordAge If Request.totalbytes>0 Then Dim Old, New1, New2 Old = Request.Form("Old") New1 = Request.Form("New1") New2 = Request.Form("New2") If New1 = New2 Then On Error Resume Next xServer.ChangePassword Old, New1 If err<>0 Then ResultHTML = "<Font color=red>" & Err.Description & ".</Font>" Else ResultHTML = "<Font color=green>Password was changed.</Font>" End If On Error Goto 0 Else ResultHTML = "<Font color=red>Password and it's confirmation does not match.</Font>" End If ' response.write "<br>Old:" & Old ' response.write "<br>New1:" & New1 ' response.write "<br>New2:" & New2 ' response.write "<br>user:" & User ' response.write "<br>PasswordExpires:" & PasswordExpires End If End If Function GetUser(UserName) Dim xServer, User Set xServer = CreateObject("UserManager.Server") Dim Pos: Pos = Instr(UserName, "\") If Pos>0 Then xServer.Select Left(UserName, Pos-1) Set User = xServer.Users(Mid(UserName, Pos+1)) Else Set User = xServer.Users(UserName) End If Set GetUser = User End Function %> <TABLE cellSpacing=1 cellPadding=3 bordercolor=silver bgcolor=GAINSBORO border=1> <form method=post > <TR> <TH> User Account</TH> <TD Align=Right><%=Request.ServerVariables("AUTH_USER")%></TD> </TR> <% Function iif(p, a, b) If p Then iif = a Else iif = b End Function If Not IsEmpty(User) Then Response.Write "<TR><TH Align=Left> Account expire</TH><TD Align=Right>" & _ iif(User.Expires, User.Expires, "never") & "</TD></TR>" Response.Write "<TR><TH Align=Left> Last logon</TH><TD Align=Right>" & _ iif(User.LastLogon, User.LastLogon, "never") & "</TD></TR>" Response.Write "<TR><TH Align=Left> Password changed</TH><TD Align=Right>" & _ CDate(Now() - User.PasswordAge) & "</TD></TR>" End If %> <TR> <TD> </TD> <TD Align=Right><input type="submit" Name="Action" value="Change password >>"></TD> </TR> <TR> <TD>Old password</TD> <TD><input size="30" name="Old" value="" type=password></TD> </TR> <TR> <TD>New password</TD> <TD><input size="30" name="New1" value="" type=password></TD> </TR> <TR> <TD>Confirm New password</TD> <TD><input size="30" name="New2" value="" type=password></TD> </TR> </form></Table> |
Properties of servers, enumerating users, logon/logoff to the user administrator account.
ActiveX UserManager is easy to use COM component with classes to create, delete and manage local and remote user accounts, groups, servers and domains in the Windows NT (2000/XP) environment. You can simple work with user accounts and groups from VBA, VBS/JS, ASP and T-SQL programming environment.
© 1996 - 2009 Antonin Foller, Motobit Software | About, Contacts | e-mail: info@pstruh.cz