private void Page_Load(object sender, System.EventArgs e)
        {
            bool passwordVerified = false;

            passwordVerified =
                AuthenticationUtilities.VerifyPassword(TxtUser.Text, "p@ssw0rD");
            if (passwordVerified)
            {
                FormsAuthentication.RedirectFromLoginPage(
                    TxtUser.Text, true);
            }
        }
Esempio n. 2
0
        private void ServerBtnLogon_Click(object sender,
                                          System.EventArgs e)
        {
            bool passwordVerified = false;

            try
            {
                passwordVerified =
                    AuthenticationUtilities.VerifyPassword(TxtUser.Text, TxtPwd.Text);
                if (passwordVerified)
                {
                    FormsAuthentication.RedirectFromLoginPage(
                        TxtUser.Text, false);
                }
                else
                {
                    lblMessage.Text = string.Format(CultureInfo.InvariantCulture, "Invalid Login");
                    Response.Redirect("logon.aspx");
                }
            }
            catch (Exception ex)
            {
                lblMessage.Text = string.Format(CultureInfo.InvariantCulture, ex.Message);
                return;
            }
            if (passwordVerified == true)
            {
                // The user is authenticated
                // At this point, an authentication ticket is normally created
                // This can subsequently be used to generate a GenericPrincipal
                // object for .NET authorization purposes
                // For details, see "How To: Use Forms authentication with
                // GenericPrincipal objects
                lblMessage.Text = string.Format(CultureInfo.InvariantCulture,
                                                Logon_aspx.LoginSuccess);
                BtnRegister.Enabled = false;
            }
            else
            {
                lblMessage.Text = string.Format(CultureInfo.InvariantCulture,
                                                Logon_aspx.InvalidUsernamePassword);
            }
        }
 public bool LogonUser(string userName, string password, string authority)
 {
     return(AuthenticationUtilities.VerifyPassword(userName, password));
 }