GetLastPasswordChangeDate (WebSecurity Ref)

Gets the date and time the user changed their password on. It takes one argument: the username to get the data from.

Syntax

WebSecurity.GetPasswordChangeDate(string username)

Example

<!DOCTYPE html>
 
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title></title>
    </head>
    <body>
      @WebSecurity.GetPasswordChangedDate(WebSecurity.CurrentUserName)
    </body>
</html>
Sponsored Links

Example 2

This example forces a user to change their password if their password is 6 months old.

@{

WebSecurity.RequireAuthenticatedUser();

if (WebSecurity.GetPasswordChangedDate(WebSecurity.CurrentUserName) < DateTime.Now.AddMonths(-6))
{
    Response.Redirect("~/account/manage?message=PasswordExpired");
}

}

In this example we simply subtract 6 months from the current date and if the users password is less than the date we subtracted, then it is older than 6 months.

See Also

GetUserId

GetLastPasswordChangeDate

GetLastPasswordFailureDate

GetuserIdFromPasswordResetToken