protected override void OnInit(EventArgs e) { base.OnInit(e); if (Context.User.Identity.IsAuthenticated) { if (null == Session["Organization"]) { if (!(Request.FilePath.Contains("ActiveOrganization.aspx") || Request.FilePath.Contains("Logoff.aspx"))) { Response.Redirect("./ActiveOrganization.aspx?redirecturl=" + HttpUtility.UrlEncode(Request.FilePath)); } else { MyGeneration.dOOdads.BusinessEntity.ClearConnectionString(); } } else { DL_WEB.DAL.Master.Organization org = Session["Organization"] as DL_WEB.DAL.Master.Organization; ProfileTopLink.Visible = ProfileBottomLink.Visible = true; lblOrganizationName.Text = ": " + org.Name; if (Session["RoleActions"] == null) { DL_WEB.DAL.Master.UserRole oUserRole = new DL_WEB.DAL.Master.UserRole(); oUserRole.Where.UserID.Operator = WhereParameter.Operand.Equal; oUserRole.Where.UserID.Value = DL_WEB.DAL.Master.User.GetUserID(Context.User.Identity.Name); oUserRole.Where.OrganizationID.Operator = WhereParameter.Operand.Equal; oUserRole.Where.OrganizationID.Value = org.OrganizationID; oUserRole.Query.Load(); DL_WEB.DAL.Master.RoleAction oRoleAction = new DL_WEB.DAL.Master.RoleAction(); DataTable dtRoleActions = oRoleAction.LoadRoleActionsByRoleID(oUserRole.RoleID); Session.Add("RoleActions", dtRoleActions); } } } }
public override bool ChangePassword(string name, string oldPassword, string newPassword) { try { if (newPassword.Length < MinRequiredPasswordLength) { return(false); } int UserID = DL_WEB.DAL.Master.User.GetUserID(name); Guid UserGuid = DL_WEB.DAL.Master.User.GetUserGUID(name); DL_WEB.DAL.Master.User oMasterUser = new DL_WEB.DAL.Master.User(); oMasterUser = new DL_WEB.DAL.Master.User(); oMasterUser.LoadByPrimaryKey(UserID); if (oldPassword != null && oldPassword != oMasterUser.Password) { return(false); } oMasterUser.Password = newPassword; oMasterUser.Save(); UserRole oUserRoles = new DL_WEB.DAL.Master.UserRole(); oUserRoles.Where.UserID.Value = UserID; oUserRoles.Query.Load(); foreach (DataRowView oUserRole in oUserRoles.DefaultView) { DataRow[] drOrg = Organization.Instance.Organizations.Select("OrganizationID = " + oUserRole["OrganizationID"]); if (drOrg.Length > 0) { int iDatabaseID = ConvertHelper.o2i(drOrg[0]["DatabaseID"]); DataRow[] drDbs = Database.Instance.Databases.Select("DatabaseID = " + iDatabaseID); string sConnectionString = ConvertHelper.o2s(drDbs[0]["DBConnectionString"]); if (drDbs.Length > 0) { DL_WEB.DAL.Client.User oClientUser = new DL_WEB.DAL.Client.User(); oClientUser.Where.GUID.Value = UserGuid; oClientUser.ConnectionString = sConnectionString; oClientUser.Query.Load(); if (oClientUser.RowCount > 0) { oClientUser.Password = newPassword; oClientUser.Save(); } } } } return(true); } catch { return(false); } }