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); }
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); }
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); }
public virtual object GetResourceDefine(HttpContext context) { YZRequest request = new YZRequest(context); string rsid = request.GetString("rsid"); UserResource resource; UserResourcePermisionCollection perms; //获得数据 using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); resource = UserResource.Open(cn, rsid); perms = UserResource.GetPermisions(cn, rsid); } return(new { resource = resource, perms = perms }); }