Example #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);
     }
 }
Example #2
0
        public Dictionary <string, string[]> GetItemSecurity(string path, out bool inheritsParentSecurity)
        {
            var permissions = new Dictionary <string, string[]>(StringComparer.CurrentCultureIgnoreCase);

            foreach (var permission in webserviceProxy.GetPolicies(path, out inheritsParentSecurity))
            {
                var roles = Array.ConvertAll(permission.Roles, r => r.Name);
                permissions.Add(permission.GroupUserName, roles);
            }

            return(permissions);
        }
        /// <summary>
        /// get security information
        /// </summary>
        private void FillSecurity()
        {
            try
            {
                bool warning;
                lvSecurity.Items.Clear();

                Policy[] policies = _reportServerProperties2005.GetPolicies(_reportPath, out warning);

                foreach (Policy policie in policies)
                {
                    var li = new ListViewItem {
                        Name = policie.GroupUserName, Text = policie.GroupUserName
                    };
                    li.SubItems.Add(String.Join(",", (policie.Roles.Where(p => p != null).Select(p => p.Name).ToArray())));
                    li.ImageKey = @"User";
                    lvSecurity.Items.Add(li);
                }
            }
            catch
            {
            }
        }