Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass credentials when accessing SSRS report through URL

I am trying to access a SSRS report using URL like below

http://MyServerIP/ReportServer?/FolderName/ReportName&Param1=ParamValue&rs:Command=Render&rs:Format=HTML4.0&rc:Toolbar=false

When I try to access above Url, I am asked for my network credentials, giving which I get all pages of SSRS report rendered in browser window.

Now I want to display these contents in a popup window inside my webApp. For this I tried to make a jquery request and get contents, but doing this I get 401 unauthorized error. So I wanna know if there is a way to send credentials in jquery ajax get request.

As a turnaround I tried using below C# code to retrieve data, but it didn't helped either and gave same 401 error

WebClient client = new WebClient();
client.Credentials = new NetworkCredential("username", "password", "domain");
divContents.InnerText = client.DownloadString(my report path);

I am using SSRS 2008 R2 and my requirement is to show all pages of report in popup window. So all pointers in this direction are welcome.

Adding a point at last, my web app and report may or may not reside on same domain.

Thanks, Ravi

like image 353
TechnicalSmile Avatar asked Apr 04 '13 16:04

TechnicalSmile


2 Answers

What I would try:

  • Create a new page. On the C# side, use the ReportExecution2005 web service to render your report to HTML. Then pump the result out to the window.

  • In your pop-up, either call the new C# page via Ajax (to get the HTML) and inject the output into your jQuery window, or pop up the page itself as a separate browser window.

I can provide some sample code if you need it.

ETA: I found a possibly valuable piece of information:

This is from the HTML Device Settings page (emphasis mine):

Toolbar

Indicates whether to show or hide the toolbar. The default of this parameter is true. If the value of this parameter is false, all remaining options (except the document map) are ignored. If you omit this parameter, the toolbar is automatically displayed for rendering formats that support it.

The Report Viewer toolbar is rendered when you use URL access to render a report. The toolbar is not rendered through the SOAP API. However, the Toolbar device information setting affects the way that the report is displayed when using the SOAP Render method. If the value of this parameter is true when using SOAP to render to HTML, only the first section of the report is rendered. If the value is false, the entire HTML report is rendered as a single HTML page.

like image 192
Ann L. Avatar answered Sep 20 '22 08:09

Ann L.


You pass the credentials like this in the query string:

dsu:DataSourceName=userName&dsp:DataSourceName=password

Replace the elements in bold with the values from your report, for example:

http://MyServerIP/ReportServer?/FolderName/ReportName&Param1=ParamValue&rs:Command=Render&rs:Format=HTML4.0&rc:Toolbar=false&dsu:Data=reportreader&dsp:Data=password1
like image 25
Jon Grant Avatar answered Sep 22 '22 08:09

Jon Grant