Add one user/group to one specified Reporting Services item
Introduction
This Visual Basic.NET sample script illustrates how to add one user or one group to a SQL Server Reporting Services item by referencing SSRS web services. This script applies to SQL Server Reporting Services 2005, 2008, 2008 R2 and 2012 versions in native
mode.
Scenarios
Add a user or a group and grant certain permission on specify item is one question frequently meet in Reporting Services administration. Traditionally, IT professionals can finish this task in Report Manager web site. Actually, using one rss script with
variables can also achieve the same effect as using UI.
Script
About how to run this script, please follow below steps:
Step1. On the Start menu, click All Programs, click
Accessories, and then click Run. In the
Open box, type CMD, and then click OK.
Screenshot:

Step2. Run the addpolicy.rss script file.
Command:
rs -i E:\onescript\addpolicy.rss -s servername/reportserver -v GrouporUserName="DomainName\userorgroupname" -v TargetItemPath="/AAA/BB/cc" -v iskeepOriginalPolicy="True" -v RoleName="Browser"
Screenshot:

Note: replace the values of the variables with yours.
-i: “E:\onescript\addpolicy.rss”, the addpolicy.rss script file locates in the local path E:\onescript.
-s: “servername/reportserver” is the target report server URL.
GrouporUserName: the user or group name that you would like to add.
TargetItemPath: the target item path that you would like to add the user or group to, it should be one path from the target report server.
iskeepOriginalPolicy: “True”, keep the original policy that existing on the item; “False”, cover the original policy of the item.
RoleName: the role type name that you would like to grant to the user or group.
Here are some code snippets for your references. To get the complete script sample, please click the download button at the beginning of this page.
Visual Basic
Edit|Remove
vb
'To check if to keep the original policy of the target item
Dim originalPermissions() As Policy
IF iskeepOriginalPolicy = "True" Then
originalPermissions = rs.GetPolicies(TargetItemPath,True)
Else
originalPermissions = Nothing
End IF
'Define one list variable to store the original policys
Dim list As New System.Collections.ArrayList(originalPermissions)
'To check if to keep the original policy of the target item Dim originalPermissions() As Policy
IF iskeepOriginalPolicy = "True"Then
originalPermissions = rs.GetPolicies(TargetItemPath,True)
Else
originalPermissions = NothingEnd IF
'Define one list variable to store the original policysDim list AsNew System.Collections.ArrayList(originalPermissions)
Additional Resources