示例#1
0
 public void AssignRole(string role, string grouporusername, string pathFolder)
 {
     try
     {
         ReportService2005.Role[] roles       = rs.ListRoles(SecurityScopeEnum.Catalog);
         ReportService2005.Role[] policyRoles = new ReportService2005.Role[1];
         pathFolder = pathFolder.Replace("//", "/");
         foreach (ReportService2005.Role item in roles)
         {
             if (item.Name.Equals(role))
             {
                 policyRoles[0] = item;
                 break;
             }
         }
         bool      inheritParent = false;
         Policy[]  policis       = rs.GetPolicies(pathFolder, out inheritParent);
         ArrayList li            = new ArrayList(policis);
         Policy    poli          = new Policy();
         poli.GroupUserName = grouporusername;
         poli.Roles         = policyRoles;
         li.Add(poli);
         rs.SetPolicies(pathFolder, (Policy[])li.ToArray(typeof(Policy)));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
示例#2
0
        public void SetItemSecurity(string itemPath, Dictionary <string, string[]> policies)
        {
            if (policies == null)
            {
                webserviceProxy.SetPolicies(itemPath, new Policy[] {});
                return;
            }

            webserviceProxy.SetPolicies(
                itemPath,
                policies.Keys.Select(userName => new Policy
            {
                GroupUserName = userName,
                Roles         = Array.ConvertAll(policies[userName], roleName =>
                {
                    var r = new Role {
                        Name = roleName
                    };
                    return(r);
                })
            })
                .Where(newPolicy => (!String.IsNullOrEmpty(newPolicy.GroupUserName)) && newPolicy.Roles.Length > 0)
                .ToArray());
        }