Tuesday, 19 June 2012

SSRS Web Service Insufficient Permissions

Error: System.Web.Services.Protocols.SoapException: The permissions granted to user are insufficient for performing this operation

I had this error recently when trying to connect to a SSRS Report Server vis Web Services using the code below.

rsExec = new ReportExecutionService();
//Get App setting valuesstring authenticationMode = "Windows";
string serverUrl = "http://server/ReportServer";
string userName = "username";
string password = "password";
string domain = "domain";
rsExec.Url = serverUrl.TrimEnd('/') +"/ReportExecution2005.asmx";
// Need to do different things depend on the authentication mode.
if (authenticationMode == SSRSAuthenticationModeEnum.Windows.ToString())
       rsExec.Credentials = CredentialCache.DefaultCredentials;
       rsExec.Credentials = new NetworkCredential(userName, password, domain);

ExecutionInfo ei = rsExec.LoadReport(reportPath, null);
rsExec.SetExecutionParameters(parameters, "en-us");
result = rsExec.Render(format, deviceInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);

The issue was that I was using "Windows" authentication and my SSRS Server was on a seperate machine to my web server. Once I changed my Authentication mode to "Forms" and provided some admin credentials it worked fine.

I beleive the issue only happens if you have multiple server environments. If the SSRS Server and Web Server are on the same machine I don't get this issue.

For reference I also found this blog post which although not helpful for me seems like it might be helpful for others.


Thursday, 26 April 2012

Connect to a SSRS Web Service from .Net

This is relatively straight forward. You have a SQL Server Reporting Services server set up somewhere with some Reports on it. Now you want to be able to connect to that Reporting Server from a .Net application to be able to dynamically interact with those reports. In my case I want to be able to run a Report and get back a PDF version of the Results.

First things first you need to connect to the Web Service and to do this you need to add a Reference to the Web Service that is exposed by Reporting Server. Select your Project in Visual Studio, Right Click and select Add Web Service.

In later versions of Visual Studio you will find you can only add Service References, but on the Add Service Reference screen if you select Advanced Options you get the option there to add a Web Reference. Note either way of doing this is fine but I just chose the Web Reference because that directly exposes access to the ReportExecutionService class and thats what we need.

Find the URL of the web service you want to use, this can be found by going to your ReportServer and adding the Web Service address onto the root URL. There are two you can use, the ReportService Web Service has a number of Report Mangement methods on it. The ReportExecution Web Service has a number of processing methods on it.You could add Web References to both into your project if you want to as you most likely would need to use both at some point.


Then in your code you can just create the following to be able to interact with the Web Service methods. Set a web service URL so that you can dynamically change which server you are pointing the code at and set some Credentials.

I will put up a seperate post soon with an example of using this web service to run a Report and retrieve a PDF version of the result within your .Net Application.