Ejemplo n.º 1
0
        private void SaveHRMemberEntity()
        {
            if (IsValid)
            {
                try
                {
                    MembershipUser user = ASSecurityManager.GetASPNETUserByMemberID(SecurityMemberID);

                    if (ddlRoles.Items.Count > 0)
                    {
                        String[] userRoles = ASSecurityManager.GetRolesByMemberID(SecurityMemberID);

                        foreach (String userRole in userRoles)
                        {
                            if (Roles.IsUserInRole(user.UserName, userRole) == true)
                            {
                                Roles.RemoveUserFromRole(user.UserName, userRole);
                            }
                        }

                        Roles.AddUserToRole(user.UserName, ddlRoles.SelectedItem.Text.Trim());
                    }

                    MiscUtil.ShowMessage(lblMessage, "Staff Roles has been Updated.", false);
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
Ejemplo n.º 2
0
        private void SaveHRMemberEntity()
        {
            if (IsValid)
            {
                try
                {
                    MembershipUser user = ASSecurityManager.GetASPNETUserByMemberID(SecurityMemberID);

                    if (user != null)
                    {
                        //user.
                        lblNewPassword.Text = user.ResetPassword();

                        MiscUtil.ShowMessage(lblMessage, "Password has been changed successfully.", false);
                    }
                    else
                    {
                        MiscUtil.ShowMessage(lblMessage, "User not found.", false);
                    }

                    PrepareInitialView();
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
Ejemplo n.º 3
0
        private void SaveHRMemberEntity()
        {
            if (IsValid)
            {
                try
                {
                    MembershipUser user = ASSecurityManager.GetASPNETUserByMemberID(SecurityMemberID);

                    if (user != null)
                    {
                        if (ASSecurityManager.ValidateASPNETUserPassword(user.UserName, txtOldPassword.Text.Trim()) == true)
                        {
                            ASSecurityManager.ChangeASPNETUserPassword(user.UserName, txtOldPassword.Text.Trim(), txtPassword.Text.Trim());

                            MiscUtil.ShowMessage(lblMessage, "Password has been changed successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Incorrect Old password.", true);
                        }
                    }
                    else
                    {
                        MiscUtil.ShowMessage(lblMessage, "User not found.", false);
                    }

                    PrepareInitialView();
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
Ejemplo n.º 4
0
        protected void btnGetPassword_Click(object sender, EventArgs e)
        {
            MembershipUser user     = ASSecurityManager.GetASPNETUserByMemberID(SecurityMemberID);
            string         password = user.ResetPassword();

            lblPassword.Text = password;
        }
Ejemplo n.º 5
0
        private void SaveHRMemberEntity()
        {
            if (IsValid)
            {
                try
                {
                    MembershipUser user = ASSecurityManager.GetASPNETUserByMemberID(SecurityMemberID);

                    if (user != null)
                    {
                        user.Email = txtEmailAddress.Text.ToString();

                        if (chkIsUserLocked.Checked == true)
                        {
                            user.IsApproved = false;
                            Membership.UpdateUser(user);
                        }
                        else
                        {
                            user.UnlockUser();
                            user.IsApproved = true;
                            Membership.UpdateUser(user);
                        }



                        MiscUtil.ShowMessage(lblMessage, "Email address has been updated successfully.", false);
                    }
                    else
                    {
                        user = ASSecurityManager.CreateASPNETUserForMember(SecurityMemberID, txtUserID.Text.Trim(), txtPassword.Text.Trim(), txtEmailAddress.Text.Trim());

                        if (chkIsUserLocked.Checked == true)
                        {
                            user.IsApproved = false;
                            Membership.UpdateUser(user);
                        }

                        MiscUtil.ShowMessage(lblMessage, "Login Information has been created successfully.", false);
                    }

                    PrepareInitialView();
                    PrepareEditView();
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
Ejemplo n.º 6
0
        private void PrepareEditView()
        {
            MembershipUser user = ASSecurityManager.GetASPNETUserByMemberID(SecurityMemberID);

            if (user != null)
            {
                txtUserID.Text            = user.UserName;
                txtUserID.ReadOnly        = true;
                txtEmailAddress.Text      = user.Email;
                divPassword.Visible       = false;
                divReTypePassword.Visible = false;
                chkIsUserLocked.Checked   = user.IsLockedOut;

                btnSubmit.Text = "Update";
            }
        }
Ejemplo n.º 7
0
        private void SetUserIDAndPasswordFromCookies()
        {
            userLoginControl.TitleText = "";

            TextBox txtUserName = (TextBox)userLoginControl.FindControl("UserName");
            TextBox txtPassword = (TextBox)userLoginControl.FindControl("Password");

            String cookieUserName = ASSecurityManager.GetUserNameFromCookies();
            String cookiePassword = ASSecurityManager.GetPasswordFromCookies();

            if (cookieUserName.IsNotNullOrEmpty() && cookiePassword.IsNotNullOrEmpty())
            {
                txtUserName.Attributes.Add("value", cookieUserName);
                txtPassword.Attributes.Add("value", cookiePassword);
            }
        }
Ejemplo n.º 8
0
        private Boolean ValidateUserInput()
        {
            Boolean isInputValid = true;

            MembershipUser user = ASSecurityManager.GetASPNETUserByMemberID(SecurityMemberID);

            if (user == null)
            {
                if (ASSecurityManager.IsUserNameAvailable(txtUserID.Text.Trim()) == false)
                {
                    isInputValid = false;

                    MiscUtil.ShowMessage(lblMessage, "User ID is not available, Please choose another.", true);
                }
            }

            return(isInputValid);
        }
Ejemplo n.º 9
0
        private void SaveMemberAccount()
        {
            try
            {
                Int64 memberID = CurrentMemberID;

                if (memberID > 0)
                {
                    if (CurrentMembershipUser != null)
                    {
                        // validating old password
                        Boolean passwordValidationResult = ASSecurityManager.ValidateASPNETUserPassword(txtUsername.Text, txtOldpassword.Text);

                        if (passwordValidationResult)
                        {
                            ASSecurityManager.ChangeASPNETUserPassword(txtUsername.Text.Trim(), txtOldpassword.Text.Trim(), txtPassword.Text.Trim());

                            MiscUtil.ShowMessage(lblMessage, "Password Changed Successfully", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Incorrect Old Password.", true);
                        }
                    }
                    else
                    {
                        MembershipUser newUser = ASSecurityManager.CreateASPNETUserForMember(CurrentMemberID, txtUsername.Text.Trim(), txtPassword.Text.Trim());

                        if (newUser != null)
                        {
                            MiscUtil.ShowMessage(lblMessage, "New user created successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to create new user.", true);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MiscUtil.ShowMessage(lblMessage, "Failed to create new user.", true);
            }
        }
Ejemplo n.º 10
0
        private void PrepareInitialView()
        {
            BuildDropDownList();

            String[] roles     = ASSecurityManager.GetAllRoles();
            String[] userRoles = ASSecurityManager.GetRolesByMemberID(SecurityMemberID);

            foreach (String role in roles)
            {
                ListItem li = new ListItem(role);

                ddlRoles.Items.Add(li);
            }

            if (userRoles != null && userRoles.Length > 0)
            {
                ddlRoles.SelectedValue = userRoles[0];
            }
        }
Ejemplo n.º 11
0
        protected void PrepareInitialView()
        {
            LoadAllRoles();

            try
            {
                txtUsername.Text = ASSecurityManager.GetASPNETUserByMemberID(CurrentMemberID).UserName;
            }
            catch (Exception ex)
            { }

            try
            {
                ddlRolename.SelectedValue = ASSecurityManager.GetRolesByMemberID(CurrentMemberID)[0];
            }
            catch (Exception ex)
            { }

            txtUsername.Enabled = false;
            btnSubmit.Text      = "Update";
        }
Ejemplo n.º 12
0
        protected void SetRoleToUSer()
        {
            try
            {
                if (txtUsername.Text.IsNotNullOrEmpty())
                {
                    String user = txtUsername.Text.Trim();

                    if (ddlRolename.SelectedItem.Text != "Select Role")
                    {
                        String role = ddlRolename.SelectedItem.Text;

                        ASSecurityManager.GetASPNETUserByUserName(user);

                        String[] users = new String[1];

                        users[0] = user;

                        #region Remove Previous Roles

                        String[] userRoles = Roles.GetRolesForUser(user);

                        foreach (String userRole in userRoles)
                        {
                            Roles.RemoveUserFromRole(user, userRole);
                        }

                        #endregion

                        Roles.AddUsersToRole(users, role);
                    }

                    MiscUtil.ShowMessage(lblMessage, "Role Assigne to " + user + " successfully.", false);
                }
            }
            catch (Exception ex)
            {
                MiscUtil.ShowMessage(lblMessage, ex.Message, true);
            }
        }
Ejemplo n.º 13
0
        protected void userLoginControl_LoggedIn(object sender, EventArgs e)
        {
            //#region TEst

            //Session["ProjectMemeberShip"] = "";

            //#endregion

            #region Performing the user's after login setps in security manager

            ASSecurityManager.UserLogedIn(userLoginControl.UserName);

            #endregion

            #region Set Password in cookies

            CheckBox chkRemeberMe = (CheckBox)userLoginControl.FindControl("RememberMe");

            if (chkRemeberMe.Checked == true)
            {
                ASSecurityManager.SetUserNameAndPasswordToCookies(userLoginControl.UserName, userLoginControl.Password);
            }

            #endregion

            #region Notification Service

            // Join into the recipient list.

            //Membership.

            //if (!string.IsNullOrEmpty(userLoginControl.UserName))
            //{
            //    NotificationAdapterLive.Instance.Join(userLoginControl.UserName);
            //}

            #endregion

            #region Redirect to page for the logged in user

            if (this.CurrentMember != null)
            {
                #region Role Wise Redirect

                //String[] roles = Roles.GetRolesForUser(userLoginControl.UserName);

                //if (roles.Length > 0 && roles[0].ToString() == "Applicant Portal")
                //{
                //    // i need to come back here.... might dont need to send the id
                //    Helper.Url.Redirect("~/CareerPortal/CPDefault.aspx", string.Empty, UrlConstants.OVERVIEW_MEMBER_ID, this.CurrentMember.MemberID.ToString());
                //}

                #endregion

                #region Redirect to return URL

                //if (Request.QueryString.HasKeys())
                //{
                //    String returnUrl = Request.QueryString["returnUrl"];

                //    returnUrl = returnUrl.Replace("_", "%");

                //    Helper.Url.Redirect(returnUrl);
                //}

                //Response.Redirect("~/Customer/MyAccount.aspx");

                #endregion

                //Response.Redirect("~/Default.aspx");
            }

            #endregion
        }