コード例 #1
0
        ///===================================================
        /// <summary>
        /// Modified Created: 03/11/2015
        /// Created By: Muhallidin Wali
        /// (description) Get alternate email list of users
        ///===================================================
        protected void Submit_Click(object sender, EventArgs e)
        {
            string alternate = "";

            alternate = UserAccountBLL.GetUserInfoAlterEmail(PasswordRecovery1.UserName);
            MembershipUser mUser = Membership.GetUser(PasswordRecovery1.UserName);

            if (mUser == null)
            {
                Panel2.Visible = true;
            }
            else
            {
                mUser.UnlockUser();
                mUser.LastActivityDate = DateTime.Now.AddMinutes(-Membership.UserIsOnlineTimeWindow);
                Membership.UpdateUser(mUser);

                Panel2.Visible = false;
                string Password = mUser.ResetPassword();
                string sEmail   = mUser.Email.ToString();

                MUser.ChangePasswordInLDAP(mUser.UserName, Password);
                if (alternate != "")
                {
                    sEmail = alternate;
                }

                SendEmail(sEmail, Password);
                //Server.Transfer("Login.aspx");
            }
        }
コード例 #2
0
        /// <summary>
        /// Modified by: Charlene Remotigue
        /// Date modiified:
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ChangePasswordPushButton_Click(object sender, EventArgs e)
        {
            try
            {
                string strNewPass = ChangePassword1.NewPassword;

                MembershipUser mUser = Membership.GetUser(User.Identity.Name);
                MembershipUser mPWD  = Membership.GetUser(User.Identity.Name);
                if (mUser.ChangePassword(ChangePassword1.CurrentPassword, strNewPass))
                {
                    MUser.ChangePasswordInLDAP(mUser.UserName, strNewPass);
                    SelectSpecialistViewType();
                    AlertMessage("Password successfully changed.");
                }
                else
                {
                    AlertMessage("Password change failed. Please re-enter your password and try again.");
                }
                //TextBox email = (TextBox)(ChangePassword1.ChangePasswordTemplateContainer.FindControl("uoTableChangePassword")).FindControl("uoTextBoxEmail");
                //if (email.Visible)
                ////{
                //    mUser.Email = email.Text;
                //    Membership.UpdateUser(mUser);
                //}
                //mUser.ChangePasswordQuestionAndAnswer(strNewPass, ChangePassword1.SecurityQuestion
            }
            catch (Exception ex)
            {
                if (ex.Message == "Non alpha numeric characters in 'newPassword' needs to be greater than or equal to '1'.")
                {
                    AlertMessage("Password must be at least 8 characters long and a combination of Alpha-Numeric and Special Characters.");
                }
                else
                {
                    AlertMessage(ex.Message);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Modified By: Charlene Remotigue
        /// Date Modified: 03/03/2012
        /// Description: add unlock user and reset password
        /// --------------------------------------------------
        /// Modified By:    Josephine Gad
        /// Date Modified:  03/03/2012
        /// Description:    Reset users last activity date when Reset and Unlock
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void uoUserList_ItemCommand(object sender, System.Web.UI.WebControls.ListViewCommandEventArgs e)
        {
            string strLogDescription;
            string strFunction;

            if (e.CommandName == "Delete")
            {
                UserAccountBLL.DeleteUser(e.CommandArgument.ToString());


                DateTime dateNow          = CommonFunctions.GetCurrentDateTime();
                string   sUserNameDeleted = e.CommandArgument.ToString();

                string   sUser    = sUserNameDeleted;
                string[] sUserArr = sUser.Split("::".ToCharArray());

                if (sUserArr.Count() > 0)
                {
                    MUser.DeactivateUserInLDAP(GlobalCode.Field2String(sUserArr[2]));
                }

                //Insert log audit trail (Gabriel Oquialda - 17/11/2011)
                strLogDescription = "User account deleted. (flagged as inactive) " + sUserNameDeleted;
                strFunction       = "uoUserList_ItemCommand";


                BLL.AuditTrailBLL.InsertLogAuditTrail(0, "", strLogDescription, strFunction, Path.GetFileName(Request.Path),
                                                      CommonFunctions.GetDateTimeGMT(dateNow), DateTime.Now, uoHiddenFieldUser.Value);

                GetUsers("", "");
            }

            else if (e.CommandName == "Unlock")
            {
                MembershipUser mUser = Membership.GetUser(e.CommandArgument.ToString());
                mUser.UnlockUser();
                mUser.LastActivityDate = DateTime.Now.AddMinutes(-Membership.UserIsOnlineTimeWindow);
                Membership.UpdateUser(mUser);
                AlertMessage("User " + e.CommandArgument.ToString() + " successfully unlocked.");
            }
            else if (e.CommandName == "Reset")
            {
                Label userRole = new Label();

                userRole = (Label)e.Item.FindControl("Label2");

                MembershipUser mUser = Membership.GetUser(e.CommandArgument.ToString());
                if (mUser.IsLockedOut)
                {
                    mUser.UnlockUser();
                }

                string str = mUser.ResetPassword();
                mUser.LastActivityDate = DateTime.Now.AddMinutes(-Membership.UserIsOnlineTimeWindow);
                Membership.UpdateUser(mUser);


                MUser.ChangePasswordInLDAP(mUser.UserName, str);

                string      sEmail         = mUser.Email.ToString();
                HiddenField AlterNateEmail = (HiddenField)e.Item.FindControl("uoHiddenFieldAlternateEmail");


                if (userRole.Text.ToString() == TravelMartVariable.RoleImmigration)
                {
                    if (AlterNateEmail.Value != "")
                    {
                        sEmail = AlterNateEmail.Value.ToString();
                    }
                }


                SendEmail(e.CommandArgument.ToString(), sEmail, str);
                //AlertMessage("User password successfully reset. New password will be emailed to user.");
                AlertMessage("New password has been sent to " + sEmail.ToString() + ".");
            }
        }
コード例 #4
0
        /// Author:         Josephine Monteza
        /// Date Created:   03/Nov/2015
        /// Description:    Get all Immigartion Users with alternate email to reset pwd
        private void AddEditImmigrationOfficers()
        {
            DataTable dtUser = null;
            DataTable dt     = null;

            string sMsg = "";

            try
            {
                CheckBox lChkSelect;
                Label    lAlternateEmail;
                Label    lUserName;
                Label    lLastName;
                Label    lFirstName;
                //Label lMiddleName;
                Label lEmail;

                string sAlternateEmail;
                string sUserName;
                string sPassword;

                string sLastName;
                string sFirstName;
                //string sMiddleName;

                string sEmail;

                dt = new DataTable();
                DataColumn col = new DataColumn("UserName", typeof(string));
                dt.Columns.Add(col);
                DataRow row = dt.NewRow();

                if (uoUserList.Items.Count > 0)
                {
                    for (int i = 0; i < uoUserList.Items.Count; i++)
                    {
                        lChkSelect = (CheckBox)uoUserList.Items[i].FindControl("uoCheckBoxSelect");
                        if (lChkSelect.Checked)
                        {
                            lUserName       = (Label)uoUserList.Items[i].FindControl("uoLblUName");
                            lAlternateEmail = (Label)uoUserList.Items[i].FindControl("uoLabelAltEmail");
                            lLastName       = (Label)uoUserList.Items[i].FindControl("uoLabelLName");
                            lFirstName      = (Label)uoUserList.Items[i].FindControl("uoLabelFName");
                            lEmail          = (Label)uoUserList.Items[i].FindControl("uoLabelEmail");


                            sUserName       = lUserName.Text;
                            sAlternateEmail = lAlternateEmail.Text;
                            sLastName       = lLastName.Text;
                            sFirstName      = lFirstName.Text;
                            // sMiddleName = "";
                            sEmail = lEmail.Text;

                            MembershipUser mUser = Membership.GetUser(sUserName);
                            if (mUser.IsLockedOut)
                            {
                                mUser.UnlockUser();
                            }

                            sPassword = mUser.ResetPassword();
                            mUser.ChangePassword(sPassword, uoTextBoxNewPassword.Text);
                            mUser.LastActivityDate = DateTime.Now.AddMinutes(-Membership.UserIsOnlineTimeWindow);
                            Membership.UpdateUser(mUser);

                            UserAccountBLL.LDAPImmigrationUpdate(sUserName, sEmail, sAlternateEmail, false);

                            //Add/modify from LDAP
                            sMsg = sMsg + "\n" + MUser.AddEditUserFromLDAP(sUserName, sFirstName, sLastName, sEmail, sPassword, "", sEmail);
                            MUser.ChangePasswordInLDAP(sUserName, uoTextBoxNewPassword.Text);

                            //remove this since they want Michael Jaworski to send the email manually to the users
                            //UserAccountBLL.EmailUserPassword(sUserName, sPassword, sAlternateEmail);

                            row      = dt.NewRow();
                            row[col] = sUserName;
                            dt.Rows.Add(row);
                        }
                    }
                }

                //extract the list instead
                dtUser = UserAccountBLL.GetImmigrationUsersToExtract(TravelMartVariable.RoleImmigration, true, uoTextBoxNewPassword.Text, dt);
                if (dtUser != null)
                {
                    if (dtUser.Rows.Count > 0)
                    {
                        CreateFile(dtUser);
                    }
                    else
                    {
                        sMsg = "No User Updated";
                    }
                }
                else
                {
                    sMsg = "No User Updated.";
                }

                AlertMessage("Information: " + sMsg);
            }
            catch (Exception ex)
            {
                AlertMessage(ex.Message);
            }
            finally
            {
                if (dtUser != null)
                {
                    dtUser.Dispose();
                }
                if (dt != null)
                {
                    dt.Dispose();
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Date Modified:  11/Nov/2015
        /// Modified By:    Josephine Monteza
        /// (description)   Add LDAP change password
        /// ===================================
        /// </summary>
        protected void ChangePasswordPushButton_Click(object sender, EventArgs e)
        {
            try
            {
                string strNewPass = NewPassword.Text;
                string strDummyPassword;
                string sMsg = "";

                if (!strNewPass.Any(char.IsUpper))
                {
                    sMsg = "Password must have uppercase ";
                }
                if (!strNewPass.Any(char.IsLower))
                {
                    if (sMsg.Trim() == "")
                    {
                        sMsg = "Password must have lowercase letter. ";
                    }
                    else
                    {
                        sMsg = sMsg + " and lowercase letter. ";
                    }
                }
                else
                {
                    if (sMsg != "")
                    {
                        sMsg = sMsg + "letter. ";
                    }
                }

                if (sMsg != "")
                {
                    AlertMessage(sMsg);
                }
                else
                {
                    MembershipUser mUser = Membership.GetUser(User.Identity.Name);
                    strDummyPassword = mUser.ResetPassword();

                    if (mUser.ChangePassword(strDummyPassword, strNewPass))
                    {
                        MUser.ChangePasswordInLDAP(mUser.UserName, strNewPass);
                        SelectSpecialistViewType();
                        AlertMessage("Password successfully changed.");
                    }
                    else
                    {
                        AlertMessage("Password change failed. Please re-enter your password and try again.");
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex.Message == "Non alpha numeric characters in 'newPassword' needs to be greater than or equal to '1'.")
                {
                    AlertMessage("Password must be at least 8 characters long and a combination of Alpha-Numeric and Special Characters.");
                }
                else
                {
                    AlertMessage(ex.Message);
                }
            }
        }
コード例 #6
0
        /// Author:         Josephine Monteza
        /// Date Created:   03/Nov/2015
        /// Description:    Get all Immigartion Users with alternate email to reset pwd
        private void AddEditImmigrationOfficers()
        {
            DataTable dtUser = null;
            DataTable dt     = null;

            string sMsg = "";

            try
            {
                DateTime dtFrom = GlobalCode.Field2DateTime(uoTextBoxFrom.Text);
                DateTime dtTo   = GlobalCode.Field2DateTime(uoTextBoxTo.Text);

                List <UserList_LDAP> list = UserAccountBLL.GetUserList(dtFrom, dtTo, TravelMartVariable.RoleImmigration, true, false, "");
                string sAlternateEmail;
                string sUserName;
                string sPassword;

                string sLastName;
                string sFirstName;
                string sMiddleName;

                string sEmail;

                dt = new DataTable();
                DataColumn col = new DataColumn("UserName", typeof(string));
                dt.Columns.Add(col);
                DataRow row = dt.NewRow();

                for (int i = 0; i < list.Count; i++)
                {
                    sUserName       = list[i].UserName;
                    sAlternateEmail = list[i].AlternateEmail;
                    sLastName       = list[i].LastName;
                    sFirstName      = list[i].FirstName;
                    sMiddleName     = list[i].MiddleName;
                    sEmail          = list[i].Email;

                    MembershipUser mUser = Membership.GetUser(sUserName);
                    if (mUser.IsLockedOut)
                    {
                        mUser.UnlockUser();
                    }

                    sPassword = mUser.ResetPassword();
                    mUser.ChangePassword(sPassword, uoTextBoxNewPassword.Text);
                    mUser.LastActivityDate = DateTime.Now.AddMinutes(-Membership.UserIsOnlineTimeWindow);
                    Membership.UpdateUser(mUser);

                    //Add/modify from LDAP
                    sMsg = sMsg + "\n" + MUser.AddEditUserFromLDAP(sUserName, sFirstName, sLastName, sEmail, sPassword, "", sEmail);
                    MUser.ChangePasswordInLDAP(sUserName, uoTextBoxNewPassword.Text);

                    //remove this since they want Michael Jaworski to send the email manually to the users
                    //UserAccountBLL.EmailUserPassword(sUserName, sPassword, sAlternateEmail);

                    row      = dt.NewRow();
                    row[col] = sUserName;
                    dt.Rows.Add(row);
                }

                //extract the list instead
                dtUser = UserAccountBLL.GetImmigrationUsersToExtract(TravelMartVariable.RoleImmigration, true, uoTextBoxNewPassword.Text, dt);
                if (dtUser != null)
                {
                    if (dtUser.Rows.Count > 0)
                    {
                        CreateFile(dtUser);
                    }
                    else
                    {
                        sMsg = "No User Updated";
                    }
                }

                AlertMessage("Information: " + sMsg);
            }
            catch (Exception ex)
            {
                AlertMessage(ex.Message);
            }
            finally
            {
                if (dtUser != null)
                {
                    dtUser.Dispose();
                }
                if (dt != null)
                {
                    dt.Dispose();
                }
            }
        }