private void btnLogin_ServerClick(object sender, System.EventArgs e) { // try to authenticate the user UserEntity user = null; SecurityManager.AuthenticateResult result = SecurityManager.AuthenticateUser(tbxUserName.Value, tbxPassword.Value, out user); switch (result) { case SecurityManager.AuthenticateResult.AllOk: // authenticated // Save session cacheable data SessionAdapter.LoadUserSessionData(user); // update last visit date in db UserManager.UpdateLastVisitDateForUser(user.UserID); // done FormsAuthentication.RedirectFromLoginPage(tbxUserName.Value, chkPersistentLogin.Checked); // Audit the login action, if it was defined to be logged for this role. if (SessionAdapter.CheckIfNeedsAuditing(AuditActions.AuditLogin)) { SecurityManager.AuditLogin(SessionAdapter.GetUserID()); } break; case SecurityManager.AuthenticateResult.IsBanned: lblErrorMessage.Text = "You are banned. Login won't work for you."; break; case SecurityManager.AuthenticateResult.WrongUsernamePassword: lblErrorMessage.Text = "You specified a wrong User name - Password combination. Try again."; break; } }