Reporting Services 2008 R2 web services api - how do I manage security permissions?

I am writing a powershell script to deploy multiple reports in SQL Server Reporting Services 2008 R2 using SSRS web services. I am very pleased with this approach, it was easy to create a new deployment folder and upload reports. Below is a code snippet showing the creation of a folder:

$reportServerUri = "http://{0}/ReportServer/ReportService2005.asmx" -f $reportServerName $proxy = New-WebServiceProxy -Uri $reportServerUri -Namespace SSRS.ReportingService2005 -Credential $credential #Dont currently set any properties so set empty array of properties $propertyArray = @() $warnings = $proxy.CreateFolder($folderName, $folderParent, $propertyArray) 

However, I would also like to be able to set permissions in the folder, and this is where I got a little stuck. What I want to replicate is where, from the web interface, I would select the security option for this folder and add the user \ group against the role.

I thought this could be done through the Array property when calling createFolder, but I still could not find any information in the documents (I probed existing properties and did not see anything appropriate), I looked at http://msdn.microsoft.com/ en-us / library / cc282788.aspx for guidance. So reached a dead end. I thought there might be a specific permission management method at this level, but he could not identify it.

I am using ReportingService2005 web services, I know that there are also 2010 web services, but I could not find what I am looking for there.

Does anyone know how I can add permissions for folders using api web services (and presumably a consistent method for other objects like reports and shared data sources)? I assume this is possible, as the web interface allows you to do this. This is not a powershell question, but instead an api for managing permissions.

Update . Below is a snippet of code that seems to do the job. I need to refine this a bit, since it looks like the policy update should include the original list, so I need to get the current policies, add a new policy to it and update the full list. But I will fix it later!

 $Policies = $global:ssrsproxy.GetPolicies($ItemPath, [ref] $InheritsFromParent) $PolicyAlreadyExists = $false $Policies | Foreach-Object{ if ($_.GroupUserName -eq $GroupUserName) {$PolicyAlreadyExists = $true} } $Policies | Foreach-Object{ $_ | get-member } if ($PolicyAlreadyExists){ "Policy already applied." } else { $Policy = New-Object SSRS.ReportingService2005.Policy $Policy.GroupUserName = $GroupUserName $Roles = @() $Role = New-Object SSRS.ReportingService2005.Role $Role.Name = $RoleName $Roles += $Role $Policy.Roles = $Roles $global:ssrsproxy.SetPolicies($ItemPath, $Policy) "Policy applied." } 
+6
source share
1 answer

Use the SetPolicies method. First, define an array Policy (s) containing the group / user and the necessary roles, then pass this array to SetPolicies along with the element.

+2
source

Source: https://habr.com/ru/post/906531/


All Articles