如何从DMZ中的ReportViewer Control查看SQL Server 2005 Reporting Services报告

时间:2022-01-09 08:13:20

I want to be able to view a SQL Server 2005 Reporting Services report from an ASP.NET application in a DMZ through a ReportViewer control. The SQLand SSRS server are behind the firewall.

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

1 个解决方案

#1


3  

`So I had to change the way an ASP.NET 2.0 application called reports from pages. Originally, I used JavaScript to open a new window.

`所以我不得不改变ASP.NET 2.0应用程序从页面调用报表的方式。最初,我使用JavaScript打开一个新窗口。

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

The issue I had was that the window.open call would only work within the client network and not on a new web server located in their DMZ. I had to create a new report WebForm that embedded a ReportViewer control to view the reports.

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

The other issue I had is that the Report Server had to be accessed with windows Authentication since it was being used by another application for reports and that app used roles for report access. So off I went to get my ReportViewer control to impersonate a windows user. I found the solution to be this:

我遇到的另一个问题是报告服务器必须使用Windows身份验证访问,因为它被另一个应用程序用于报告,而该应用程序使用角色进行报告访问。所以,我去了我的ReportViewer控件来冒充Windows用户。我发现解决方案是这样的:

Create a new class which implements the Microsoft.Reporting.WebForms.IReportServerCredentials interface for accessing the reports.

创建一个新类,该类实现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;
    }
}

Then I created an event for the button to call the report:

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

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();
}

#1


3  

`So I had to change the way an ASP.NET 2.0 application called reports from pages. Originally, I used JavaScript to open a new window.

`所以我不得不改变ASP.NET 2.0应用程序从页面调用报表的方式。最初,我使用JavaScript打开一个新窗口。

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

The issue I had was that the window.open call would only work within the client network and not on a new web server located in their DMZ. I had to create a new report WebForm that embedded a ReportViewer control to view the reports.

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

The other issue I had is that the Report Server had to be accessed with windows Authentication since it was being used by another application for reports and that app used roles for report access. So off I went to get my ReportViewer control to impersonate a windows user. I found the solution to be this:

我遇到的另一个问题是报告服务器必须使用Windows身份验证访问,因为它被另一个应用程序用于报告,而该应用程序使用角色进行报告访问。所以,我去了我的ReportViewer控件来冒充Windows用户。我发现解决方案是这样的:

Create a new class which implements the Microsoft.Reporting.WebForms.IReportServerCredentials interface for accessing the reports.

创建一个新类,该类实现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;
    }
}

Then I created an event for the button to call the report:

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

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();
}