MembershipUser.LastPasswordChangedDate 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
멤버 자격 사용자의 암호를 마지막으로 업데이트한 날짜와 시간을 가져옵니다.
public:
virtual property DateTime LastPasswordChangedDate { DateTime get(); };
public virtual DateTime LastPasswordChangedDate { get; }
member this.LastPasswordChangedDate : DateTime
Public Overridable ReadOnly Property LastPasswordChangedDate As DateTime
속성 값
멤버 자격 사용자의 암호를 마지막으로 수정한 날짜 및 시간입니다.
예제
다음 코드 예제에서는 지정된 일 수 후에 암호가 만료되었음을 나타내는 로그인 페이지를 보여 줍니다. LastPasswordChangedDate 가 현재 날짜 및 시간보다 이전이고 암호 만료에 지정된 일 수를 뺀 경우 사용자에게 암호를 변경하라는 지시가 표시됩니다.
중요
이 예제에서는 잠재적 보안 위협을 사용자 입력을 허용 하는 텍스트 상자가 포함 되어 있습니다. 기본적으로 ASP.NET 웹 페이지는 사용자 입력 내용에 스크립트 또는 HTML 요소가 포함되어 있지 않은지 확인합니다. 자세한 내용은 Script Exploits Overview를 참조하세요.
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Security" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
double passwordExpiresDays = 90;
public void Login_OnClick(object sender, EventArgs args)
{
MembershipUser u = Membership.GetUser(UsernameTextbox.Text);
if (u == null)
{
Msg.Text = "Invalid user name. Please check your user name and try again.";
return;
}
if (Membership.ValidateUser(UsernameTextbox.Text, PasswordTextbox.Text))
{
if (u.LastPasswordChangedDate.AddDays(passwordExpiresDays) < DateTime.Now)
{
Msg.Text = "Your password has expired. Please change your password to a new value.";
UsernameLabel.Text = UsernameTextbox.Text;
ChangePasswordPanel.Visible = true;
LoginPanel.Visible = false;
}
else
{
FormsAuthentication.RedirectFromLoginPage(UsernameTextbox.Text, NotPublicCheckBox.Checked);
}
}
else
{
Msg.Text = "Invalid password. Please check your password and try again.";
}
}
public void ChangePassword_OnClick(object sender, EventArgs args)
{
// Update the password.
MembershipUser u = Membership.GetUser(UsernameLabel.Text);
if (u.ChangePassword(OldPasswordTextbox.Text, NewPasswordTextbox.Text))
{
Msg.Text = "Password changed.";
ChangePasswordPanel.Visible = false;
LoginPanel.Visible = true;
}
else
{
Msg.Text = "Password change failed. Please re-enter your values and try again.";
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Login</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Login</h3>
<asp:Label id="Msg" ForeColor="maroon" runat="server" /><br />
<asp:Panel id="LoginPanel" runat="Server">
Username: <asp:Textbox id="UsernameTextbox" runat="server" /><br />
Password: <asp:Textbox id="PasswordTextbox" runat="server" TextMode="Password" /><br />
<asp:Button id="LoginButton" Text="Login" OnClick="Login_OnClick" runat="server" />
<asp:CheckBox id="NotPublicCheckBox" runat="server" /> Check here if this is <span style="text-decoration:underline">not</span> a public computer.
</asp:Panel>
<asp:Panel id="ChangePasswordPanel" runat="Server" Visible="False">
<table cellpadding="3" border="0">
<tr>
<td>Username:</td>
<td><b><asp:Label id="UsernameLabel" runat="server" /></b></td>
<td></td>
</tr>
<tr>
<td>Old Password:</td>
<td><asp:Textbox id="OldPasswordTextbox" runat="server" TextMode="Password" /></td>
<td><asp:RequiredFieldValidator id="OldPasswordRequiredValidator" runat="server"
ControlToValidate="OldPasswordTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td>Password:</td>
<td><asp:Textbox id="NewPasswordTextbox" runat="server" TextMode="Password" /></td>
<td><asp:RequiredFieldValidator id="PasswordRequiredValidator" runat="server"
ControlToValidate="NewPasswordTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td>Confirm Password:</td>
<td><asp:Textbox id="PasswordConfirmTextbox" runat="server" TextMode="Password" /></td>
<td><asp:RequiredFieldValidator id="PasswordConfirmRequiredValidator" runat="server"
ControlToValidate="PasswordConfirmTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" />
<asp:CompareValidator id="PasswordConfirmCompareValidator" runat="server"
ControlToValidate="PasswordConfirmTextbox" ForeColor="red"
Display="Static" ControlToCompare="PasswordTextBox"
ErrorMessage="Confirm password must match password." />
</td>
</tr>
<tr>
<td></td>
<td><asp:Button id="ChangePasswordButton" Text="Change Password"
OnClick="ChangePassword_OnClick" runat="server" /></td>
</tr>
</table>
</asp:Panel>
</form>
<br />
</body>
</html>
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Web.Security" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Dim passwordExpiresDays As Double = 90
Public Sub Login_OnClick(sender As Object, args As EventArgs)
Dim u As MembershipUser = Membership.GetUser(UsernameTextbox.Text)
If u Is Nothing Then
Msg.Text = "Invalid user name. Please check your user name and try again."
Return
End If
If Membership.ValidateUser(UsernameTextbox.Text, PasswordTextbox.Text) Then
If u.LastPasswordChangedDate.AddDays(passwordExpiresDays) < DateTime.Now Then
Msg.Text = "Your password has expired. Please change your password to a new value."
UsernameLabel.Text = UsernameTextbox.Text
ChangePasswordPanel.Visible = True
LoginPanel.Visible = False
Else
FormsAuthentication.RedirectFromLoginPage(UsernameTextbox.Text, NotPublicCheckBox.Checked)
End If
Else
Msg.Text = "Invalid password. Please check your password and try again."
End If
End Sub
Public Sub ChangePassword_OnClick(sender As Object, args As EventArgs)
' Update the password.
Dim u As MembershipUser = Membership.GetUser(UsernameLabel.Text)
If u.ChangePassword(OldPasswordTextbox.Text, NewPasswordTextbox.Text) Then
Msg.Text = "Password changed."
ChangePasswordPanel.Visible = False
LoginPanel.Visible = True
Else
Msg.Text = "Password change failed. Please re-enter your values and try again."
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Login</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Login</h3>
<asp:Label id="Msg" ForeColor="maroon" runat="server" /><br />
<asp:Panel id="LoginPanel" runat="Server">
Username: <asp:Textbox id="UsernameTextbox" runat="server" /><br />
Password: <asp:Textbox id="PasswordTextbox" runat="server" TextMode="Password" /><br />
<asp:Button id="LoginButton" Text="Login" OnClick="Login_OnClick" runat="server" />
<asp:CheckBox id="NotPublicCheckBox" runat="server" /> Check here if this is <span style="text-decoration:underline">not</span> a public computer.
</asp:Panel>
<asp:Panel id="ChangePasswordPanel" runat="Server" Visible="False">
<table cellpadding="3" border="0">
<tr>
<td>Username:</td>
<td><b><asp:Label id="UsernameLabel" runat="server" /></b></td>
<td></td>
</tr>
<tr>
<td>Old Password:</td>
<td><asp:Textbox id="OldPasswordTextbox" runat="server" TextMode="Password" /></td>
<td><asp:RequiredFieldValidator id="OldPasswordRequiredValidator" runat="server"
ControlToValidate="OldPasswordTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td>Password:</td>
<td><asp:Textbox id="NewPasswordTextbox" runat="server" TextMode="Password" /></td>
<td><asp:RequiredFieldValidator id="PasswordRequiredValidator" runat="server"
ControlToValidate="NewPasswordTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td>Confirm Password:</td>
<td><asp:Textbox id="PasswordConfirmTextbox" runat="server" TextMode="Password" /></td>
<td><asp:RequiredFieldValidator id="PasswordConfirmRequiredValidator" runat="server"
ControlToValidate="PasswordConfirmTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" />
<asp:CompareValidator id="PasswordConfirmCompareValidator" runat="server"
ControlToValidate="PasswordConfirmTextbox" ForeColor="red"
Display="Static" ControlToCompare="PasswordTextBox"
ErrorMessage="Confirm password must match password." />
</td>
</tr>
<tr>
<td></td>
<td><asp:Button id="ChangePasswordButton" Text="Change Password"
OnClick="ChangePassword_OnClick" runat="server" /></td>
</tr>
</table>
</asp:Panel>
</form>
<br />
</body>
</html>
설명
는 SqlMembershipProvider , , LastLoginDateLastActivityDate및 LastPasswordChangedDate 날짜를 메서드에 의해 CreateUser 멤버 자격 사용자가 생성되는 날짜와 시간으로 설정합니다CreationDate.
적용 대상
추가 정보
.NET