Exemple #1
0
        public virtual JObject GetResourcePerms(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            string    rsid    = request.GetString("rsid");
            JObject   rv      = new JObject();

            //获得数据
            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();

                UserResource userResource = UserResource.Open(cn, rsid);
                rv["ResourceName"] = userResource.ResourceName;

                UserResourcePermisionCollection perms = UserResource.GetPermisions(cn, rsid);
                URACL acl = UserResource.GetACL(cn, rsid);

                JArray jperms = new JArray();
                rv["perms"] = jperms;
                foreach (UserResourcePermision perm in perms)
                {
                    JObject jperm = JObject.FromObject(perm);
                    jperms.Add(jperm);
                    JArray jRoles = new JArray();
                    jperm["roles"] = jRoles;
                    BPMObjectNameCollection checkedSids = new BPMObjectNameCollection();

                    foreach (URACE ace in acl.ACEs)
                    {
                        if (checkedSids.Contains(ace.SID))
                        {
                            continue;
                        }

                        checkedSids.Add(ace.SID);

                        SecurityToken token = new SecurityToken();
                        token.SIDs.Add(ace.SID);
                        if (acl.HasPermision(token, perm.PermName))
                        {
                            JObject jRole = new JObject();
                            jRoles.Add(jRole);

                            jRole["Name"] = ace.GetSIDDisplayName(cn);
                        }
                    }
                }
            }

            return(rv);
        }
Exemple #2
0
        public virtual JObject GetACL(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            string    rsid    = request.GetString("rsid");

            JObject rv = new JObject();

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();

                UserResource userResource             = UserResource.Open(cn, rsid);
                UserResourcePermisionCollection perms = UserResource.GetPermisions(cn, rsid);
                URACL acl = UserResource.GetACL(cn, rsid);

                JArray jperms = new JArray();
                rv["perms"] = jperms;
                foreach (UserResourcePermision perm in perms)
                {
                    JObject jperm = new JObject();
                    jperms.Add(jperm);

                    jperm["PermName"]        = perm.PermName;
                    jperm["PermType"]        = perm.PermType.ToString();
                    jperm["PermDisplayName"] = perm.PermDisplayName;
                }

                JObject jacl = new JObject();
                rv["acl"] = jacl;

                JArray jaces = new JArray();
                jacl["aces"] = jaces;

                foreach (URACE ace in acl.ACEs)
                {
                    //获得ACE角色的显示名
                    string displayName = ace.GetSIDDisplayName(cn);
                    if (String.IsNullOrEmpty(displayName))
                    {
                        continue;
                    }

                    JObject jace = JObject.FromObject(ace);
                    jaces.Add(jace);

                    jace["DisplayName"] = displayName;
                }
            }

            return(rv);
        }