1 CS 3870/CS 5870: Note 12 Membership Class
2 Logging in User Programmatically If Membership.ValidateUser(txtUserName.Text, txtPassword.Text) Then FormsAuthetication.RedirectFromLoginPage(...) Else lblErr.Text = “Incorrect UserName or Password!” End If
Invalid Password <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version= , Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUnique ="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/> 3
4 Locking Out User with Bad Password If Membership.ValidateUser(txtUserName.Text, txtPassword.Text) Then FormsAuthetication.RedirectFromLoginPage(...) Else Dim user As MembershipUser = Membership.GetUser(txtUserName.Text) lblErr.Text = “Locked out value: ” & user.IsLockedout().ToString() End If
5 Unlocking a User Dim user As MembershipUser = MembershipGetUser(txtUserName.Text) user.UnlockUser()
Showing Number of Users Online Page_Load Event lblNumUsers.Text = “There are ” & Membership.GetNumberOfUsersOnline().ToString() 6
7 Lab5MasterPage The LoginName and LoginStatus should be displayed to the left side and right side of "Lab 5", respectively. Code (VB or C#) file Protected Sub LoginStatus1_LoggedOut(...) Handles... Response.Redirect("~/Login.aspx") End Sub
Lab 5 8