How to pass credentials when accessing SSRS report through URL

27,560

Solution 1

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

Solution 2

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.

Solution 3

You can use the Report Viewer control if you want to allow public access to secure reports without asking for credentials.

  1. Create a new .aspx page and use the ReportViewer control like so:

    <rsweb:ReportViewer ID="MainReportViewer" runat="server" BackColor="White" 
        Font-Names="Verdana" Font-Size="8pt" InteractiveDeviceInfos=" (Collection)" 
        ProcessingMode="Remote" ShowBackButton="False" ShowFindControls="False" 
        ShowPageNavigationControls="False" SizeToReportContent="True" 
        ToolBarItemBorderColor="White" ToolBarItemHoverBackColor="White" 
        WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Width="100%">
            <ServerReport ReportServerUrl="" />
    </rsweb:ReportViewer>
    
  2. The code below can be used in the codebehind of your .aspx page to configure the report server, username and password, [etc..] in your Report Viewer

    protected void Page_Init(Object sender, EventArgs e)
    {
        string UserName = ConfigurationManager.AppSettings["SsrsUserName"];
        string Password = ConfigurationManager.AppSettings["SsrsPassword"];
        string Domain = ConfigurationManager.AppSettings["SsrsDomain"];
        string ReportServerRoot = ConfigurationManager.AppSettings["SsrsServerRoot"];
        string ReportServerPath = ConfigurationManager.AppSettings["SsrsReportServerPath"];
        MainReportViewer.ProcessingMode = ProcessingMode.Remote;
        IReportServerCredentials irsc = new CustomReportCredentials(UserName, Password, Domain);
        MainReportViewer.ServerReport.ReportServerCredentials = irsc;
        MainReportViewer.ServerReport.ReportServerUrl = new Uri(ReportServerRoot);
        MainReportViewer.ServerReport.ReportPath = ReportServerPath + "YourReportFileName";
    }
    
Share:
27,560
TechnicalSmile
Author by

TechnicalSmile

I am fun, nature and music lover and I like traveling a lot. On professional front I am a .NET developer working majorly on Web Applications. For fun, sometimes I use PHP as well.

Updated on April 17, 2020

Comments

  • TechnicalSmile
    TechnicalSmile about 4 years

    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

  • TechnicalSmile
    TechnicalSmile about 11 years
    Thanks Ann, this was a way but problem here is render gives only one page at a time and I need to show whole report in a go. Any idea if its possible with this approach? MSDN doc suggests "Subsequent calls to Render can be used to fetch additional pages of the report if the rendering extension supports specifying multiple pages.", I am trying to look into this
  • Ann L.
    Ann L. about 11 years
    Would rending it as a PDF be acceptable? The report execution service Render method will return the entire PDF in one call.
  • TechnicalSmile
    TechnicalSmile about 11 years
    that is the last resort that I have already proposed to others. Could it be displayed in a modal popup window. I mean user clicked a link, a postback happened, pdf got created using ReportExecution2005 and that pdf got displayed in some modal popup. I am not sure for last step "pdf got displayed in modal popup". Any thoughts?
  • Ann L.
    Ann L. about 11 years
    I think it would have to be displayed in its own browser window (or possibly in an IFRAME). You could try putting an IFRAME in a DIV and making the DIV into a modal jQuery dialog.
  • Ann L.
    Ann L. about 11 years
    I did a little more research and found some information that I think might help. I apologize if you've already seen it. I added it to my answer.
  • Snehal
    Snehal about 7 years
    is it really working this? For me it still asking prompt for credential. Please help if having any solution or anything else need to pass along with this settings?
  • et3rnal
    et3rnal over 5 years
    I believe this is not for the report server but the manager. So you have to be authenticated first then this will let you access the passed datasource reports etc which is not what this question about.