Ejemplo n.º 1
0
        protected void Login1_LoginError(object sender, EventArgs e)
        {
            //There was a problem logging in the user

            //See if this user exists in the database
            MembershipUser userInfo = Membership.GetUser(Login2.UserName);

            if (userInfo == null)
            {
                //The user entered an invalid username...
                ((Label)Login2.FindControl("LoginErrorDetails")).Text = "There is no user in the database with the username " + Login2.UserName;
            }
            else
            {
                //See if the user is locked out or not approved
                if (!userInfo.IsApproved)
                {
                    ((Label)Login2.FindControl("LoginErrorDetails")).Text =
                        "Your account has not yet been approved by the site's administrators. Please try again later...";
                }
                else if (userInfo.IsLockedOut)
                {
                    ((Label)Login2.FindControl("LoginErrorDetails")).Text =
                        "Your account has been locked out because of a maximum number of incorrect Login attempts. You will NOT be able to Login until you contact a site administrator and have your account unlocked.";
                }
                else
                {
                    //The password was incorrect (don't show anything, the Login control already describes the problem)
                    ((Label)Login2.FindControl("LoginErrorDetails")).Text = String.Empty;
                }
            }
        }
Ejemplo n.º 2
0
    private bool SiteSpecificAuthenticationMethod(string UserName, string Password)
    {
        SqlConnection Dbconn  = new SqlConnection(ConfigurationManager.ConnectionStrings["SSIRentConnectionString"].ToString());
        CheckBox      cek     = (CheckBox)Login2.FindControl("RememberMe");
        string        cmdtext = "Select FirstName,LastName,USERID,[User] from usysPasswords where [User] = @User and Password = @Password";

        SqlCommand cmd = new SqlCommand(cmdtext, Dbconn);

        Dbconn.Open();
        cmd.Parameters.AddWithValue("@User", UserName);
        cmd.Parameters.AddWithValue("@Password", Password);

        try
        {
            SqlDataReader dr = cmd.ExecuteReader();
            if (dr.HasRows)
            {
                dr.Read();
                Session["Name"]     = dr["FirstName"].ToString() + " " + dr["LastName"].ToString();
                Session["USERID"]   = dr["USERID"].ToString();
                Session["UserName"] = dr["User"].ToString();
                //FormsAuthentication.SetAuthCookie(Login2.UserName,true);
                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
                                                                                 Login2.UserName,
                                                                                 DateTime.Now,
                                                                                 DateTime.Now.AddMinutes(120),
                                                                                 false, "ApplicationSpecific data for this user.",
                                                                                 FormsAuthentication.FormsCookiePath);
                //encrypt ticket
                string encTicket = FormsAuthentication.Encrypt(ticket);
                Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));
                //if (cek.Checked)
                //{
                //    HttpCookie cookie = new HttpCookie("username");
                //    cookie.Value = Login2.UserName;

                //    cookie.Expires = DateTime.Now.AddDays(1);//cookie Expires
                //    HttpContext.Current.Response.AppendCookie(cookie);
                //}
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (Exception ex)
        {
            return(false);
        }
        finally
        {
            Dbconn.Close();
            Dbconn.Dispose();
            cmd.Dispose();
        }
    }
Ejemplo n.º 3
0
        private void Authenticate(AuthenticateEventArgs e)
        {
            string company = string.Empty;
            var    ctl     = Login2.FindControl("Company");

            if (ctl != null)
            {
                company = ((TextBox)ctl).Text;
            }

            if (_prioritizerService.Authenticate(Login2.UserName, Prioritizer.Shared.Utils.EncodePassword(Login2.Password), company) != null)
            {
                e.Authenticated = true;
            }
            else
            {
                e.Authenticated = false;
            }
        }
Ejemplo n.º 4
0
        private bool SiteSpecificAuthenticationMethod(string UserName, string Password)
        {
            using (SSIRentEntities context = new SSIRentEntities())
            {
                var user = context.Database.SqlQuery <User>("exec sp_SYS_GetUserCredentials @UserName, @Password",
                                                            new SqlParameter("UserName", UserName), new SqlParameter("Password", Password)).ToList();

                if (user.Count > 0)
                {
                    CheckBox cek = (CheckBox)Login2.FindControl("RememberMe");
                    Session["Name"]     = user[0].Firstname + " " + user[0].LastName;
                    Session["USERID"]   = user[0].UserID;
                    Session["UserName"] = UserName;
                    FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
                                                                                     Login2.UserName,
                                                                                     DateTime.Now,
                                                                                     DateTime.Now.AddMinutes(120),
                                                                                     false, "ApplicationSpecific data for this user.",
                                                                                     FormsAuthentication.FormsCookiePath);
                    //encrypt ticket
                    string encTicket = FormsAuthentication.Encrypt(ticket);
                    Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));
                    //if (cek.Checked)
                    //{
                    //    HttpCookie cookie = new HttpCookie("username");
                    //    cookie.Value = Login2.UserName;
                    //    //    cookie.Expires = DateTime.Now.AddDays(1);//cookie Expires
                    //    HttpContext.Current.Response.AppendCookie(cookie);
                    //}
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }