【问题标题】:How do you view SQL Server 2005 Reporting Services reports from ReportViewer Control in DMZ如何从 DMZ 中的 ReportViewer 控件查看 SQL Server 2005 Reporting Services 报告
【发布时间】:2010-09-08 23:56:46
【问题描述】:

我希望能够通过 ReportViewer 控件从 DMZ 中的 ASP.NET 应用程序查看 SQL Server 2005 Reporting Services 报告。 SQLand SSRS 服务器位于防火墙后面。

【问题讨论】:

    标签: asp.net reporting-services reportviewer reportingservices-2005


    【解决方案1】:

    `所以我不得不改变 ASP.NET 2.0 应用程序从页面调用报告的方式。本来我是用JavaScript打开一个新窗口的。

    ViewCostReport.OnClientClick = "window.open('" + Report.GetProjectCostURL(_PromotionID) + "','ProjectCost','resizable=yes')";
    

    我遇到的问题是 window.open 调用只能在客户端网络中工作,而不能在位于其 DMZ 中的新 Web 服务器上工作。我必须创建一个嵌入 ReportViewer 控件的新报表 WebForm 来查看报表。

    我遇到的另一个问题是必须使用 Windows 身份验证访问报表服务器,因为它正被另一个应用程序用于报表,并且该应用程序使用角色来访问报表。所以我开始使用我的 ReportViewer 控件来模拟 Windows 用户。我发现解决方案是这样的:

    创建一个实现用于访问报告的 Microsoft.Reporting.WebForms.IReportServerCredentials 接口的新类。

    public class ReportCredentials : Microsoft.Reporting.WebForms.IReportServerCredentials
    {
        string _userName, _password, _domain;
        public ReportCredentials(string userName, string password, string domain)
        {
            _userName = userName;
            _password = password;
            _domain = domain;
        }
    
        public System.Security.Principal.WindowsIdentity ImpersonationUser
        {
            get
            {
                return null;
            }
        }
    
        public System.Net.ICredentials NetworkCredentials
        {
            get
            {
                return new System.Net.NetworkCredential(_userName, _password, _domain);
            }
        }
    
        public bool GetFormsCredentials(out System.Net.Cookie authCoki, out string userName, out string password, out string authority)
        {
            userName = _userName;
            password = _password;
            authority = _domain;
            authCoki = new System.Net.Cookie(".ASPXAUTH", ".ASPXAUTH", "/", "Domain");
            return true;
        }
    }
    

    然后我为按钮创建了一个事件来调用报告:

    protected void btnReport_Click(object sender, EventArgs e)
    {
        ReportParameter[] parm = new ReportParameter[1];
        parm[0] =new ReportParameter("PromotionID",_PromotionID);
        ReportViewer.ShowCredentialPrompts = false;
        ReportViewer.ServerReport.ReportServerCredentials = new ReportCredentials("Username", "Password", "Domain");
        ReportViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
        ReportViewer.ServerReport.ReportServerUrl = new System.Uri("http://ReportServer/ReportServer");
        ReportViewer.ServerReport.ReportPath = "/ReportFolder/ReportName";
        ReportViewer.ServerReport.SetParameters(parm);
        ReportViewer.ServerReport.Refresh();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多