/// <summary> /// Modified By: Charlene Remotigue /// Date Modified: 03/03/2012 /// Description: add unlock user and reset password /// </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(); //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(); AlertMessage("User " + e.CommandArgument.ToString() + " successfully unlocked."); } else if (e.CommandName == "Reset") { MembershipUser mUser = Membership.GetUser(e.CommandArgument.ToString()); string str = mUser.ResetPassword(); string sEmail = mUser.Email.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 " + mUser.Email + "."); } }
/// <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() + "."); } }