[英]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;之后,把
iframe
的src
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.