all groups > sql server reporting services > february 2007 >
You're in the

sql server reporting services

group:

How to programatically add users as browser to reports


How to programatically add users as browser to reports Raghu
2/21/2007 6:29:10 AM
sql server reporting services: Hi,

I have a requirement to add 100 users (Windows) as browsers to view a
report. I was wondering if I can use some reportserver webservice
method to automate these kinds of bulk permission assignments. Can you
please help me which method comes close to assiging permissions to
users, if it is possible at all.

Thanks
RE: How to programatically add users as browser to reports mikey
2/21/2007 8:56:10 AM
If you can - create an NT group with all the Users that need to view it,
and just create a one-off assignment in reporting services to give browser
permissions for that group.


[quoted text, click to view]
Re: How to programatically add users as browser to reports Smokey Grindle
2/21/2007 12:17:08 PM
You can use the following in VB.NET to set a permission on an object, its a
start


''' <summary>

''' Set security roles for the given item

''' </summary>

''' <param name="userOrGroupName"></param>

''' <param name="rolesIn"></param>

''' <param name="itemPath"></param>

''' <param name="keepCurrentPolicies"></param>

''' <returns></returns>

''' <remarks></remarks>

Private Shared Function SetSecurityPolicy(ByVal userOrGroupName As String,
ByVal rolesIn() As String, ByVal itemPath As String, ByVal
keepCurrentPolicies As Boolean, ByVal inheritFromParent As Boolean) As
Boolean

Try

Dim isRoot As Boolean = False

Dim inheritParent As Boolean = inheritFromParent

Dim policies() As ReportServer.Policy

Dim newPolicies() As ReportServer.Policy

Dim policy As New ReportServer.Policy()

Dim roles(rolesIn.Length - 1) As ReportServer.Role

For i As Integer = 0 To rolesIn.Length - 1

roles(i) = New ReportServer.Role()

roles(i).Name = rolesIn(i).Trim

Next

policy.Roles = roles

policy.GroupUserName = userOrGroupName

'While Not isRoot

' ' Once the root of the catalog is reached,

' ' stop applying policies

' If itemPath = "/" Then

' isRoot = True

' End If

policies = server.GetPolicies(itemPath, inheritParent)

' If the user selects not to keep inherited or current policy,

' empty the policy

If Not keepCurrentPolicies = True Then

policies = Nothing

End If

newPolicies = AddNewPolicy(policy, policies)

server.SetPolicies(itemPath, newPolicies)

itemPath = GetParentPath(itemPath)

'End While

debug.writeline("Successfully set policy for: " & itemPath)

Catch ex As Exception

Debug.WriteLine(ex.ToString)

debug.writeline(ex.Message)

End Try

End Function

''' <summary>

''' Takes the policy to add and applies it to the current set

''' of policies if applicable

''' </summary>

''' <param name="policyToAdd"></param>

''' <param name="policies"></param>

''' <returns></returns>

''' <remarks></remarks>

Private Shared Function AddNewPolicy(ByVal policyToAdd As
ReportServer.Policy, ByVal policies() As ReportServer.Policy) As
ReportServer.Policy()

If Not (policies Is Nothing) Then

Dim policy As ReportServer.Policy

For Each policy In policies

If policy.GroupUserName = policyToAdd.GroupUserName Then

Throw New Exception("The supplied User policy already exists for the item.")

End If

Next policy

Dim list As New System.Collections.ArrayList(policies)

list.Add(policyToAdd)

Return CType(list.ToArray(GetType(ReportServer.Policy)),
ReportServer.Policy())

Else

policies = New ReportServer.Policy(0) {}

policies(0) = policyToAdd

Return policies

End If

End Function 'AddNewPolicy

Re: How to programatically add users as browser to reports Raghu
3/4/2007 10:07:16 PM
Thanks a lot for the prompt replies. Creating a windows NT user groups
worked for me here.
AddThis Social Bookmark Button