Example #1
0
        private void BtnRegister_Click(object sender,
                                       System.EventArgs e)
        {
            string salt         = AuthenticationUtilities.CreateSalt(5);
            string passwordHash =
                AuthenticationUtilities.CreatePasswordHash(TxtPwd.Text, salt);

            if (AuthenticationUtilities.ValidateUserName(TxtUser.Text))
            {
                try
                {
                    AuthenticationUtilities.StoreAccountDetails(
                        TxtUser.Text, passwordHash, salt);
                }
                catch (Exception ex)
                {
                    lblMessage.Text = string.Format(CultureInfo.InvariantCulture, ex.Message);
                }
            }
            else
            {
                lblMessage.Text = string.Format(CultureInfo.InvariantCulture,
                                                Logon_aspx.UserNameError);
            }
        }
        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);
            }
        }
        private void BtnLogon_Click(object sender, System.EventArgs e)
        {
            bool passwordVerified = false;

            try
            {
                ReportServerProxy server = new ReportServerProxy();

                string reportServer = ConfigurationManager.AppSettings["ReportServer"];
                string instanceName = ConfigurationManager.AppSettings["ReportServerInstance"];

                // Get the server URL from the report server using WMI
                server.Url = AuthenticationUtilities.GetReportServerUrl(reportServer, instanceName);

                server.LogonUser(TxtUser.Text, TxtPwd.Text, null);

                passwordVerified = true;
            }
            catch (Exception ex)
            {
                lblMessage.Text = string.Format(CultureInfo.InvariantCulture, ex.Message);
                return;
            }
            if (passwordVerified == true)
            {
                lblMessage.Text = string.Format(CultureInfo.InvariantCulture,
                                                UILogon_aspx.LoginSuccess);
                string redirectUrl =
                    Request.QueryString["ReturnUrl"];
                if (redirectUrl != null)
                {
                    HttpContext.Current.Response.Redirect(redirectUrl, false);
                }
                else
                {
                    HttpContext.Current.Response.Redirect(
                        "./Folder.aspx", false);
                }
            }
            else
            {
                lblMessage.Text = string.Format(CultureInfo.InvariantCulture,
                                                UILogon_aspx.InvalidUsernamePassword);
            }
        }
Example #4
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));
 }