Beispiel #1
0
    private void StoreUserInfo()
    {
        DL_WEB.DAL.Master.User oMasterUser = new DL_WEB.DAL.Master.User();

        if (0 != UserID)
        {
            oMasterUser.LoadByPrimaryKey(UserID);

            if (0 != oMasterUser.RowCount)
            {
                oMasterUser.IsInactive = cbIsInactive.Checked;
                oMasterUser.IsApproved = cbIsApproved.Checked;
                oMasterUser.Login      = tbLogin.Text;
                oMasterUser.Email      = tbLogin.Text;
            }
        }
        else
        {
            oMasterUser.AddNew();
            oMasterUser.IsInactive       = cbIsInactive.Checked;
            oMasterUser.IsApproved       = cbIsApproved.Checked;
            oMasterUser.Login            = tbLogin.Text;
            oMasterUser.Email            = tbLogin.Text;
            oMasterUser.GUID             = Guid.NewGuid();
            oMasterUser.Password         = oMasterUser.GUID.ToString();
            oMasterUser.PasswordQuestion = "?";
            oMasterUser.IsLockedOut      = false;
            oMasterUser.CreationDate     = DateTime.Now;
        }

        Session["MasterUser"] = oMasterUser;

        DL_WEB.DAL.Client.User oClientUser = FillClientUser(oMasterUser);

        Session.Add("ClientUser", oClientUser);
    }
Beispiel #2
0
    private DL_WEB.DAL.Master.User LoadMasterUserInfo()
    {
        DL_WEB.DAL.Master.User oMasterUser = null;
        if (null != Session["MasterUser"])
        {
            oMasterUser = Session["MasterUser"] as DL_WEB.DAL.Master.User;
        }
        else
        {
            oMasterUser = new DL_WEB.DAL.Master.User();
            oMasterUser.LoadByPrimaryKey(UserID);

            if (oMasterUser.RowCount == 0)
            {
                return(null);
            }
        }

        this.tbLogin.Text         = oMasterUser.Login;
        this.cbIsApproved.Checked = oMasterUser.IsApproved;

        if (this.UserID > 0)
        {
            if (!oMasterUser.IsColumnNull(DL_WEB.DAL.Master.User.ColumnNames.IsInactive))
            {
                this.cbIsInactive.Checked = oMasterUser.IsInactive;
            }
        }
        else
        {
            cbIsInactive.Checked = true;
            cbIsInactive.Enabled = false;
        }

        return(oMasterUser);
    }
Beispiel #3
0
        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);
            }
        }