Esempio n. 1
0
        public virtual JObject GetACL(HttpContext context)
        {
            YZRequest request    = new YZRequest(context);
            string    rsid       = request.GetString("rsid");
            string    table      = request.GetString("table");
            string    key        = request.GetString("key");
            string    datasource = request.GetString("datasource", null);

            JObject rv = new JObject();

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

                UserResource userResource             = UserResource.Open(cn, rsid);
                UserResourcePermisionCollection perms = UserResource.GetPermisions(cn, rsid);
                RDACL acl = RecordSecurityManager.LoadACL(cn, table, key, datasource);

                JArray jperms = new JArray();
                rv["perms"] = jperms;
                foreach (UserResourcePermision perm in perms)
                {
                    if (perm.PermType != UserResourcePermisionType.Record)
                    {
                        continue;
                    }

                    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;

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

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

                    jace["DisplayName"] = displayName;
                }
            }

            return(rv);
        }
Esempio n. 2
0
        protected virtual RDACECollection URACEs2RDACEs(URACECollection uraces)
        {
            RDACECollection rdaces = new RDACECollection();

            foreach (URACE urace in uraces)
            {
                if (urace.AllowPermision.Count == 0)
                {
                    urace.AllowPermision.Add("");
                }

                foreach (string permision in urace.AllowPermision)
                {
                    RDACE rdace = new RDACE();
                    rdaces.Add(rdace);

                    rdace.SIDType         = urace.SIDType;
                    rdace.SID             = urace.SID;
                    rdace.Permision       = permision;
                    rdace.LeadershipToken = urace.LeadershipTokenPermision.Contains(permision);
                }
            }

            return(rdaces);
        }
Esempio n. 3
0
        protected virtual URACE FindURACE(URACECollection uraces, RDACE rdace)
        {
            foreach (URACE urace in uraces)
            {
                if (urace.SIDType == rdace.SIDType &&
                    urace.SID == rdace.SID)
                {
                    return(urace);
                }
            }

            return(null);
        }
Esempio n. 4
0
        public virtual void SaveACL(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            string    rsid    = request.GetString("rsid");

            JArray          post = request.GetPostData <JArray>();
            URACECollection aces = post.ToObject <URACECollection>(request.Serializer);

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                URACL acl = new URACL();
                acl.RSID = rsid;
                acl.ACEs = aces;

                UserResource.SaveACL(cn, acl);
            }
        }
Esempio n. 5
0
        public virtual void SaveACL(HttpContext context)
        {
            YZRequest request    = new YZRequest(context);
            string    rsid       = request.GetString("rsid");
            string    table      = request.GetString("table");
            string    key        = request.GetString("key");
            string    datasource = request.GetString("datasource", null);

            JArray          post   = request.GetPostData <JArray>();
            URACECollection uraces = post.ToObject <URACECollection>(request.Serializer);

            RDACECollection rdaces = this.URACEs2RDACEs(uraces);

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                RDACL acl = new RDACL();
                acl.ACEs = rdaces;

                RecordSecurityManager.SaveACL(cn, table, key, acl, datasource);
            }
        }
Esempio n. 6
0
        protected virtual URACECollection RDACEs2URACEs(RDACECollection rdaces)
        {
            URACECollection uraces = new URACECollection();

            foreach (RDACE rdace in rdaces)
            {
                URACE urace = this.FindURACE(uraces, rdace);
                if (urace != null)
                {
                    if (!urace.AllowPermision.Contains(rdace.Permision))
                    {
                        urace.AllowPermision.Add(rdace.Permision);
                    }
                }
                else
                {
                    urace = new URACE();
                    uraces.Add(urace);
                    urace.SIDType = rdace.SIDType;
                    urace.SID     = rdace.SID;
                    urace.AllowPermision.Add(rdace.Permision);

                    if (rdace.LeadershipToken)
                    {
                        urace.LeadershipTokenPermision.Add(rdace.Permision);
                    }

                    urace.Inherited   = false;
                    urace.Inheritable = false;
                    urace.CreateDate  = rdace.CreateDate;
                    urace.CreateBy    = rdace.CreateBy;
                }
            }

            return(uraces);
        }