1

I have an Iframe through which I will call the reporting service

<iframe src="@(ViewBag.ReportUrl)" id="ifReport" scrolling="yes" height="500" width="100%"></iframe>

each time I try to call this service it is asking for credentials

enter image description here

Is there any way to avoid this prompt. My web applications use Active Directory Credentials for login, So the same credentials are used here. Can I use that credentials while calling this service to avoid the prompt? I have already referred to https://stackoverflow.com/a/12166240/10325225 . But that answer got me nowhere

<AuthenticationTypes>
            <RSWindowsNTLM/>
        </AuthenticationTypes>
        <RSWindowsExtendedProtectionLevel>Off</RSWindowsExtendedProtectionLevel>
        <RSWindowsExtendedProtectionScenario>Proxy</RSWindowsExtendedProtectionScenario>
        <EnableAuthPersistence>true</EnableAuthPersistence>
    </Authentication>

these are authentication provided in the RSReportServer.config. I know that there is a way to implement custom Authentication. Apart from that is there any method for a single time sign in

MITHUN VS
  • 65
  • 7

2 Answers2

0

I figured out the solution. To view a report in an iframe, you must first make a small ASP.NET Web Forms project with a page with a ReportViewer control inside:

<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>

<form id="form1" runat="server">
       <asp:ScriptManager runat="server"></asp:ScriptManager>
       <rsweb:ReportViewer ID="ReportViewer1" runat="server" >
       </rsweb:ReportViewer>
 </form>

ReportViewer1.ProcessingMode = ProcessingMode.Remote;
CustomReportCredentials irsc = new CustomReportCredentials(userName,password, domain); // if you dont have a domain enter computer name
ReportViewer1.ServerReport.ReportServerCredentials = irsc;
ReportViewer1.ServerReport.ReportServerUrl = host/reportServer not portal;
ReportViewer1.ServerReport.ReportPath = important! <report path with folder that contains report.rdl>;

After that, put in the iframe's src URL to the webform project; e.g.,

localhost/ReportPage.aspx

You can find an example of class CustomReportCredentials :IReportServerCredentials if you search on Google.

Redman
  • 1
  • 1
0

In ReportPage.aspx

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

  <form id="CommonReport" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <rsweb:ReportViewer ID="ReportViewer1" runat="server" Height="100%" Width="100%">
    </rsweb:ReportViewer>
</form>  

In ReportPage.aspx.cs

namespace ReportWebForm
{
     public partial class ReportPage:SystemWeb.Ui.Page
         {
             if(!IsPostBack)
             {
               CustomReportCredentials  irsc = new CustomReportCredentials(userName, password,domain) //if you dont have domain enter computer name
             ReportViewer1.ProcessingMode = ProcessingMode.Remote;
             ReportViewer1.ServerReport.ReportServerCredentials = irsc;
         ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://<ssrs ip>/ReportServer"); 
             ReportViewer1.ServerReport.ReportPath = "ReportFolder/Report1";
             }
         }

      [Serializable]
      public class CustomReportCredentials : IReportServerCredentials
        {
            private string reportServerUserName;
            private string reportServerPassword;
            private string reportServerDomain;
    
            public CustomReportCredentials(string userName, string password, string domain)
            {
                reportServerUserName = userName;
                reportServerPassword = password;
                reportServerDomain = domain;
            }
            public WindowsIdentity ImpersonationUser
            {
                get
                {
                    // Use default identity.
                    return null;
                }
            }
    
            public ICredentials NetworkCredentials
            {
                get
                {
                    // Use default identity.
                    return new NetworkCredential(reportServerUserName, reportServerPassword, reportServerDomain);
                }
            }
            public void New(string userName, string password, string domain)
            {
                reportServerUserName = userName;
                reportServerPassword = password;
                reportServerDomain = domain;
            }
    
            public bool GetFormsCredentials(out Cookie authCookie, out string user, out string password, out string authority)
            {
                // Do not use forms credentials to authenticate.
                authCookie = null;
                user = null;
                password = null;
                authority = null;
    
                return false;
            }
        }

}
Redman
  • 1
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 28 '22 at 00:01