简体   繁体   English

Reporting Services 提示输入凭据

[英]Reporting Services prompts for Credentials

I have an Iframe through which I will call the reporting service我有一个 Iframe,我将通过它呼叫报告服务

<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每次我尝试调用此服务时,它都会要求提供凭据

在此处输入图像描述

Is there any way to avoid this prompt.有什么办法可以避免这个提示。 My web applications use Active Directory Credentials for login, So the same credentials are used here.我的 web 应用程序使用 Active Directory 凭据进行登录,因此此处使用相同的凭据。 Can I use that credentials while calling this service to avoid the prompt?我可以在调用此服务时使用该凭据来避免出现提示吗? I have already referred to https://stackoverflow.com/a/12166240/10325225 .我已经提到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.这些是 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除此之外还有什么方法可以单次登录

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:要在iframe中查看报告,您必须首先制作一个小的 ASP.NET Web Forms 项目,其中包含一个包含ReportViewer控件的页面:

<%@ 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;之后,把iframesrc URL放到webform项目中; eg,例如,

localhost/ReportPage.aspx

You can find an example of class CustomReportCredentials:IReportServerCredentials if you search on Google.如果您在 Google 上搜索,您可以找到class CustomReportCredentials:IReportServerCredentials的示例。

In ReportPage.aspx在 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在 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;
            }
        }

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Telerik Reporting Services - Telerik Reporting Services SQL Server Reporting Services不兼容 - SQL Server Reporting Services Incompatible MVC Windows身份验证提示输入Windows凭据并忽略自定义错误配置 - MVC Windows Authentication prompts for windows credentials and ignores custom error configuration 在VS 2012上启用Reporting Services 2005 - Enabling Reporting Services 2005 on VS 2012 重新启动后自动启动 Microsoft Reporting Services - Automatically Start Microsoft Reporting Services after a Restart IIS与Sql Server Reporting Services冲突 - IIS conflict with Sql Server Reporting Services SQL Server Reporting Services Reporting Services树在mvc应用程序中使用iframe导航 - SQL Server Reporting Services Reporting Services Tree Navigation with out iframe in mvc application 使用Firefox和Chrome时,使用Azure ACS和ADFS的MVC3站点会不断提示输入凭据 - MVC3 site using Azure ACS & ADFS continually prompts for credentials when using Firefox and Chrome 我可以以编程方式登录到Reporting Services并重定向到该页面吗? - Can I programatically log into Reporting Services and Redirect to the page? ASP.NET MVC和SQL Server Reporting Services - ASP.NET MVC & SQL Server Reporting Services
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM