Exemplo n.º 1
0
        private static AclInfo GetAcl(Dictionary <int, AclInfo> acls, int entityId)
        {
            AclInfo acl = null;

            acls.TryGetValue(entityId, out acl);
            return(acl);
        }
Exemplo n.º 2
0
        private static void SetAcl(SecurityContext context, int entityId, bool isInherited, string src)
        {
            // "+U1:____++++,+G1:____++++"
            var entity = context.GetSecurityEntity(entityId);

            var aclInfo = new AclInfo(entityId)
            {
                Entries = src.Split(',').Select(x => CreateAce(x)).ToList()
            };

            var emptyGuidArray = new List <int>();
            var breaked        = false;
            var unbreaked      = false;

            if (entity.IsInherited && !isInherited)
            {
                breaked = true;
            }
            if (!entity.IsInherited && isInherited)
            {
                unbreaked = true;
            }
            context.SetAcls(
                new[] { aclInfo },
                breaked ? new List <int> {
                entityId
            } : new List <int>(),
                unbreaked ? new List <int> {
                entityId
            } : new List <int>()
                );
            return;
        }
Exemplo n.º 3
0
        private void SetAcl(SecurityContext context, int entityId, bool isInherited, string src)
        {
            // "+U1:____++++,+G1:____++++"
            var entity = context.GetSecurityEntity(entityId);

            var aclInfo = new AclInfo(entityId)
            {
                Entries = src.Split(',').Select(CreateAce).ToList()
            };

            var @break    = false;
            var undoBreak = false;

            if (entity.IsInherited && !isInherited)
            {
                @break = true;
            }
            if (!entity.IsInherited && isInherited)
            {
                undoBreak = true;
            }
            context.SetAcls(
                new[] { aclInfo },
                @break ? new List <int> {
                entityId
            } : new List <int>(),
                undoBreak ? new List <int> {
                entityId
            } : new List <int>()
                );
        }
Exemplo n.º 4
0
 protected void btnQry_Click(object sender, EventArgs e)
 {
     divQryResult.Visible = false;
     if (!string.IsNullOrEmpty(ucCascadingDropDown.ucSelectedValue03))
     {
         divQryResult.Visible = true;
         ucAclInfo.ucAclInfo  = AclInfo.findAclInfo(ucCascadingDropDown.ucSelectedValue03, true);
         ucAclInfo.Refresh();
     }
 }
Exemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AclInfo.Init(true);
        UserInfo oUser        = UserInfo.getUserInfo();
        bool     IsAllowAdmin = false;

        divError.Visible     = true;
        divAdminArea.Visible = false;
        labErrMsg.Text       = Util.getHtmlMessage(Util.HtmlMessageKind.Error, AclRS.Resources.Msg_AclAdminDeny);

        if (Util.getAppSetting("app://AdminUserID/").ToUpper() == oUser.UserID.ToUpper())
        {
            IsAllowAdmin = true;
        }
        if (!IsAllowAdmin && _Dic_AclAdminUserList != null && _Dic_AclAdminUserList.Count > 0)
        {
            if (_Dic_AclAdminUserList.ContainsKey(oUser.UserID))
            {
                IsAllowAdmin = true;
            }
        }

        if (!IsAllowAdmin)
        {
            string[] AreaList = AclInfo.getAclInfo().getAdminAreaList();
            if (AreaList != null && AreaList.Length > 0)
            {
                IsAllowAdmin = true;
            }
        }

        if (IsAllowAdmin)
        {
            _AreaID              = Util.getRequestQueryStringKey("AreaID");
            divError.Visible     = false;
            divAdminArea.Visible = true;
            RefreshTreeView();
        }
    }
 void IPlasticAPI.CalculateAcl(string server, ObjectInfo obj, out AclInfo aclInfo, out AclEntry[] calculatedPermissions, out bool bIsOwner)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 7
0
    /// <summary>
    /// 重新整理
    /// </summary>
    public void Refresh()
    {
        if (ucAclInfo != null)
        {
            divAclInfo.Visible           = true;
            labErrMsg.Visible            = false;
            TabContainer1.ActiveTabIndex = 0;

            DataTable dtTemp;
            Dictionary <string, Dictionary <string, string> > oMap;
            Dictionary <string, string> oDicDisp;
            string strGrantName;

            //個人
            txtUserInfo.ucTextData = string.Format("{0} - {1}", ucAclInfo.UserID, UserInfo.findUserName(ucAclInfo.UserID));

            //角色
            StringBuilder sb = new StringBuilder();
            if (ucAclInfo.RuleList.Length > 0)
            {
                txtRuleInfo.ucRows = ucAclInfo.RuleList.Length + 1;
                for (int i = 0; i < ucAclInfo.RuleList.Length; i++)
                {
                    sb.AppendLine(string.Format("{0} [{1}]", ucAclInfo.RuleList[i], dicAclRule[ucAclInfo.RuleList[i]]));
                }
            }
            txtRuleInfo.ucTextData = sb.ToString();

            //詳情
            labAclInfo.Text = AclInfo.getAclInfoPage(ucAclInfo.UserID);

            //使用權限
            dtTemp = new DataTable();
            dtTemp.Columns.Add("AreaID");
            dtTemp.Columns.Add("GrantID");
            dtTemp.Columns.Add("AreaName");
            dtTemp.Columns.Add("GrantName");
            dtTemp.Columns.Add("ActList");

            oMap = ucAclInfo.AuthMap;
            foreach (var area in oMap)
            {
                foreach (var grant in oMap[area.Key])
                {
                    strGrantName = dicAclAreaGrant.ContainsKey(area.Key + "|" + grant.Key) ? dicAclAreaGrant[area.Key + "|" + grant.Key] : "N/A";
                    dtTemp.Rows.Add(area.Key, grant.Key, string.Format("{0} - {1}", area.Key, dicAclArea[area.Key]), strGrantName, grant.Value);
                }
            }

            oDicDisp = new Dictionary <string, string>();
            oDicDisp.Clear();
            oDicDisp.Add("GrantID", "項目代號");
            oDicDisp.Add("GrantName", "項目名稱");
            oDicDisp.Add("ActList", "授予權限");
            gvAuthMap.ucDataDisplayDefinition = oDicDisp;

            gvAuthMap.ucDataGroupKey         = "AreaName";
            gvAuthMap.ucGroupHeaderFormat    = "《{0}》";
            gvAuthMap.ucDataKeyList          = "AreaID,GrantID".Split(',');
            gvAuthMap.ucDataQryTable         = dtTemp;
            gvAuthMap.ucExportAllField       = true;
            gvAuthMap.ucExportOpenXmlEnabled = true;
            gvAuthMap.Refresh(true);

            //管理權限
            dtTemp = new DataTable();
            dtTemp.Columns.Add("AreaID");
            dtTemp.Columns.Add("AdminType");
            dtTemp.Columns.Add("AdminTypeName");
            dtTemp.Columns.Add("GrantID");
            dtTemp.Columns.Add("AreaName");
            dtTemp.Columns.Add("GrantName");

            oMap = ucAclInfo.AdminMap;
            string[] grantList;
            foreach (var area in oMap)
            {
                foreach (var adminType in oMap[area.Key])
                {
                    grantList = oMap[area.Key][adminType.Key].Split(',');
                    for (int i = 0; i < grantList.Count(); i++)
                    {
                        if (!string.IsNullOrEmpty(grantList[i]))
                        {
                            //略過空白項目
                            strGrantName = dicAclAreaGrant.ContainsKey(area.Key + "|" + grantList[i]) ? dicAclAreaGrant[area.Key + "|" + grantList[i]] : "N/A";
                            dtTemp.Rows.Add(area.Key, adminType.Key
                                            , string.Format("{0} - {1}", adminType.Key, dicAclAdminType[adminType.Key])
                                            , grantList[i], string.Format("{0} - {1}", area.Key, dicAclArea[area.Key]), strGrantName);
                        }
                    }
                }
            }

            oDicDisp = new Dictionary <string, string>();
            oDicDisp.Clear();
            oDicDisp.Add("AdminTypeName", "管理類型@L150");
            oDicDisp.Add("GrantID", "項目代號");
            oDicDisp.Add("GrantName", "項目名稱");
            gvAdminMap.ucDataDisplayDefinition = oDicDisp;

            gvAdminMap.ucDataGroupKey         = "AreaName";
            gvAdminMap.ucGroupHeaderFormat    = "《{0}》";
            gvAdminMap.ucDataKeyList          = "AreaID,AdminType".Split(',');
            gvAdminMap.ucDataQryTable         = dtTemp;
            gvAdminMap.ucExportAllField       = true;
            gvAdminMap.ucExportOpenXmlEnabled = true;
            gvAdminMap.Refresh(true);
        }
    }
Exemplo n.º 8
0
    public void RefreshTreeView()
    {
        TreeView1.Nodes.Clear();
        TreeNode tRootNode = new TreeNode();

        tRootNode.Text             = "ACL資料查詢";
        tRootNode.NavigateUrl      = string.Format(_ContentUrlFormat, AclExpress._AclSysPath + "AclInfo.aspx");
        tRootNode.PopulateOnDemand = false;
        tRootNode.Expanded         = true;
        TreeView1.Nodes.Add(tRootNode);

        //管理專用
        if (AclExpress.IsAclAdminUser())
        {
            //Acl 管理員專用
            TreeNode tManageNode = new TreeNode();
            tManageNode.Text         = "管理作業";
            tManageNode.Expanded     = true;
            tManageNode.SelectAction = TreeNodeSelectAction.Expand;
            tRootNode.ChildNodes.Add(tManageNode);

            TreeNode tBaseNode = new TreeNode();
            tBaseNode.Text         = "基本資料";
            tBaseNode.Expanded     = true;
            tBaseNode.SelectAction = TreeNodeSelectAction.Expand;
            tManageNode.ChildNodes.Add(tBaseNode);

            TreeNode tChildNode = new TreeNode();
            tChildNode.Text             = "區域資料(AclArea)";
            tChildNode.PopulateOnDemand = false;
            tChildNode.Expanded         = false;
            tChildNode.SelectAction     = TreeNodeSelectAction.Select;
            tChildNode.NavigateUrl      = string.Format(_ContentUrlFormat, "AclArea.aspx");
            tBaseNode.ChildNodes.Add(tChildNode);

            tChildNode                  = new TreeNode();
            tChildNode.Text             = "規則資料(AclRule)";
            tChildNode.PopulateOnDemand = false;
            tChildNode.Expanded         = false;
            tChildNode.SelectAction     = TreeNodeSelectAction.Select;
            tChildNode.NavigateUrl      = string.Format(_ContentUrlFormat, "AclRule.aspx");
            tBaseNode.ChildNodes.Add(tChildNode);

            TreeNode tAdminNode = new TreeNode();
            tAdminNode.Text         = "管理權";
            tAdminNode.Expanded     = true;
            tAdminNode.SelectAction = TreeNodeSelectAction.Expand;
            tManageNode.ChildNodes.Add(tAdminNode);

            tChildNode                  = new TreeNode();
            tChildNode.Text             = "規則<->區域(AclAdminRuleArea)"; //AclAdminRuleArea
            tChildNode.PopulateOnDemand = false;
            tChildNode.Expanded         = false;
            tChildNode.SelectAction     = TreeNodeSelectAction.Select;
            tChildNode.NavigateUrl      = string.Format(_ContentUrlFormat, "AclAdminRuleArea.aspx");
            tAdminNode.ChildNodes.Add(tChildNode);

            tChildNode                  = new TreeNode();
            tChildNode.Text             = "使用者<->區域(AclAdminUserArea)"; //AclAdminUserArea
            tChildNode.PopulateOnDemand = false;
            tChildNode.Expanded         = false;
            tChildNode.SelectAction     = TreeNodeSelectAction.Select;
            tChildNode.NavigateUrl      = string.Format(_ContentUrlFormat, "AclAdminUserArea.aspx");
            tAdminNode.ChildNodes.Add(tChildNode);

            tAdminNode              = new TreeNode();
            tAdminNode.Text         = "使用權";
            tAdminNode.Expanded     = true;
            tAdminNode.SelectAction = TreeNodeSelectAction.Expand;
            tManageNode.ChildNodes.Add(tAdminNode);

            tChildNode                  = new TreeNode();
            tChildNode.Text             = "規則<->區域(AclAuthRuleArea)"; //AclAuthRuleArea
            tChildNode.PopulateOnDemand = false;
            tChildNode.Expanded         = false;
            tChildNode.SelectAction     = TreeNodeSelectAction.Select;
            tChildNode.NavigateUrl      = string.Format(_ContentUrlFormat, "AclAuthRuleArea.aspx");
            tAdminNode.ChildNodes.Add(tChildNode);

            tChildNode                  = new TreeNode();
            tChildNode.Text             = "使用者<->區域(AclAuthUserArea)"; //AclAuthUserArea
            tChildNode.PopulateOnDemand = false;
            tChildNode.Expanded         = false;
            tChildNode.SelectAction     = TreeNodeSelectAction.Select;
            tChildNode.NavigateUrl      = string.Format(_ContentUrlFormat, "AclAreaSelect.aspx");
            tAdminNode.ChildNodes.Add(tChildNode);

            tAdminNode              = new TreeNode();
            tAdminNode.Text         = "工具";
            tAdminNode.Expanded     = true;
            tAdminNode.SelectAction = TreeNodeSelectAction.Expand;
            tManageNode.ChildNodes.Add(tAdminNode);

            tChildNode                  = new TreeNode();
            tChildNode.Text             = "CodeMap";
            tChildNode.PopulateOnDemand = false;
            tChildNode.Expanded         = false;
            tChildNode.SelectAction     = TreeNodeSelectAction.Select;
            tChildNode.NavigateUrl      = string.Format(_ContentUrlFormat, string.Format("{0}?DBName={1}&LogDBName={2}", Util._CodeMapAdminUrl, AclExpress._AclDBName, AclExpress._AclLogDBName));
            tAdminNode.ChildNodes.Add(tChildNode);

            tChildNode                  = new TreeNode();
            tChildNode.Text             = "AppLog";
            tChildNode.PopulateOnDemand = false;
            tChildNode.Expanded         = false;
            tChildNode.SelectAction     = TreeNodeSelectAction.Select;
            tChildNode.NavigateUrl      = string.Format(_ContentUrlFormat, string.Format("{0}?DBName={1}&AllowPurgeYN=Y", Util._AppLogQryUrl, AclExpress._AclDBName));
            tAdminNode.ChildNodes.Add(tChildNode);
        }

        //一般授權作業
        string[] tAreaList = AclInfo.getAclInfo().getAdminAreaList();
        if (tAreaList != null && tAreaList.Length > 0)
        {
            string[] tGrantIDList = AclInfo.getAclInfo().getAdminAreaGrantList(tAreaList[0]);
            if (tGrantIDList != null && !string.IsNullOrEmpty(tGrantIDList[0]))
            {
                //確定有資料才產生 TreeNode
                TreeNode tAreaNode = new TreeNode();
                tAreaNode.Text         = "一般授權";
                tAreaNode.Expanded     = true;
                tAreaNode.SelectAction = TreeNodeSelectAction.Expand;
                tRootNode.ChildNodes.Add(tAreaNode);

                DataTable dtArea = AclExpress.getAclAreaData().Select(string.Format(" AreaID in ('{0}') and IsEnabled = 'Y' ", Util.getStringJoin(tAreaList, "','"))).CopyToDataTable();
                if (dtArea != null && dtArea.Rows.Count > 0)
                {
                    for (int i = 0; i < dtArea.Rows.Count; i++)
                    {
                        DataRow dr = dtArea.Rows[i];
                        //AreaID 節點
                        TreeNode tChildNode = new TreeNode();
                        tChildNode.PopulateOnDemand = false;
                        tChildNode.Text             = string.Format("{0}【{1}】", dr["AreaID"], dr["AreaName"]);
                        tChildNode.NavigateUrl      = string.Format(_ContentUrlFormat, string.Format("{0}?AreaID={1}&IsDebug=Y", AclExpress._AclSysPath + "AclAuthUserArea.aspx", dr["AreaID"]));
                        tChildNode.Expanded         = false;
                        tChildNode.SelectAction     = TreeNodeSelectAction.Select;
                        tAreaNode.ChildNodes.Add(tChildNode);
                        //AddStepNodes(tSpecNode, dr["FlowID"].ToString());
                    }
                }
            }
        }
    }