コード例 #1
0
        public static UserObject GetUserData(String username, String pass, String loginAs)
        {
            UserManagementDataContext db = BasePage.GetDatabaseContext();

            int adminID = -1;

            var resU = from u in db.Users where u.UserName == username select u;
            s_Us = resU.SingleOrDefault();

            if ((s_Us != null) && (s_Us.Lockout == false))
            {
                if (ValidateUser(username, pass))
                {
                    if ((s_Us.Roles.Select(r => r.RoleID == 1).Count() == 1) && (loginAs != ""))
                    {
                        adminID = s_Us.UserID;
                        username = loginAs;
                        resU = from u in db.Users where u.UserName == loginAs select u;
                        s_Us = resU.SingleOrDefault();
                    }
                    if ((s_Us != null) && (s_Us.Lockout == false))
                    {
                        Dictionary<string, List<Right>> pagePermissionList = BuildPagePermissionList();
                        String permissionList = db.fnGetPermissionsList(s_Us.UserID);
                        UserObject userobj = new UserObject(username, s_Us, adminID, permissionList, pagePermissionList);

                        return userobj;
                    }
                }
            }
            return null;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Request.Cookies.Clear();
            mnuMain.Items.Clear();
            m_User = (UserObject)Session["User"];

            if (m_User != null)
            {
                lblLoggedInAs.Visible = true;
                lblLoggedInAs.Text = string.Concat(GetLocalResourceObject("LoggedInAs"), " ", m_User.UserName, "    |    ");
                linkLogout.Visible = true;
                lblVersion.Visible = true;
                lblVersion.Text = ConfigurationManager.AppSettings["version"];
                if (MenuList == null)
                    FetchMenu();
                BuildMenu(mnuMain, dsMenuItems);
                Session["User"] = m_User;
				
            }

            HiddenField field = new HiddenField
            {
                ID = "SessionID",
                Value = Session.SessionID
            };
            Page.Form.Controls.Add(field);
            lblError.Text = "";
        }
コード例 #3
0
 public static bool HasRightForPage(UserObject user, string page, Right r)
 {
     if (user != null)
         if (user.PagePermissionList.Keys.Contains(page))
             if (user.PagePermissionList[page].Contains(r))
                 return true;
     return false;
 }
コード例 #4
0
 public static bool CanSeeDetail(UserObject user, string page, int id)
 {
     //if (id != -1)
     //{
     //    if ((page == "~/UserDetail.aspx") && (BaseUserControl.canSeeUser(user.UserID, id)))
     //        return true;
     //    else if ((page == "~/RoleDetail.aspx") && (BaseUserControl.canSeeRole(user.UserID, id)))
     //        return true;
     //    return false;
     //}
     return true;
 }
コード例 #5
0
        public static StringBuilder GetContext(UserObject userobj)
        {
            List<contextparam> cpList = new List<contextparam>();
            contextparams cps = new contextparams();
            contextparam cp = new contextparam
            {
                key = "UserID",
                Value = userobj.UserID.ToString()
            };
            cpList.Add(cp);
            cp = new contextparam
            {
                key = "AdminID",
                Value = userobj.AdminID.ToString()
            };
            cpList.Add(cp);
            cp = new contextparam
            {
                key = "LCID",
                Value = Thread.CurrentThread.CurrentCulture.LCID.ToString()
            };
            cpList.Add(cp);
            cp = new contextparam
            {
                key = "default_LCID",
                Value = "1033"
            };
            cpList.Add(cp);
            cp = new contextparam
            {
                key = "PermissionIDs",
                Value = userobj.Permissions
            };
            cpList.Add(cp);

            if (userobj.UserID == 1)
            {
                cp = new contextparam
                {
                    key = "Override_Delete",
                    Value = "1"
                };
                cpList.Add(cp);
            }

            contextparam[] array = cpList.ToArray<contextparam>();
            cps.contextparam = array;

            XmlSerializer ser = new XmlSerializer(typeof(contextparams));
            StringBuilder sb = new StringBuilder();
            XmlWriterSettings set = new XmlWriterSettings
            {
                OmitXmlDeclaration = true
            };
            XmlWriter xml = XmlWriter.Create(sb, set);
            ser.Serialize(xml, cps);
            return sb;
        }