【问题标题】:Reporting Services Authentication issueReporting Services 身份验证问题
【发布时间】:2011-04-18 06:40:15
【问题描述】:

我正在尝试使用 Azure Reporting Services 以编程方式呈现 PDF。我怀疑实际的 PDF 检索很好,但在请求报告(通过 URL)之前我找不到验证连接的方法。我在我的 Web 应用程序的服务层工作,我不能使用 Web 引用(可能不适用于 Azure),并且使用 ReportViewer 控件没有意义(因为它是一种服务层方法)。

我有所有要连接的详细信息,但我怀疑我需要一个 cookie 来进行身份验证,但我不确定如何手动创建它。有什么建议/解决方案吗?

到目前为止,这是我的代码:

string userName = BJConfigurationManager.GetSetting("ReportingServiceUsername");
string password = BJConfigurationManager.GetSetting("ReportingServicePassword");
NetworkCredential networkCredential = new NetworkCredential(userName, password);
Domain.Report report = GetReportById(id);

int timeout = 30; //seconds
string url = "https://bleh.ctp.reporting.database.windows.net/ReportServer/Pages/ReportViewer.aspx?...";
string destinationFileName = "@C:\\Temp.pdf";

// Create a web request to the URL
HttpWebRequest MyRequest = (HttpWebRequest)WebRequest.Create(url);
MyRequest.PreAuthenticate = true;
MyRequest.Credentials = networkCredential;
MyRequest.Timeout = timeout * 1000;
try
{
    // Get the web response -- THE RESPONSE COMES BACK AS UNAUTHENTICATED...
    HttpWebResponse MyResponse = (HttpWebResponse)MyRequest.GetResponse();

【问题讨论】:

    标签: authentication reporting-services azure


    【解决方案1】:

    查看标题为“SOAP 管理端点编程访问”的部分: http://msdn.microsoft.com/en-us/library/windowsazure/771e88b6-ab0f-4910-a5fa-5facd8d56767#SOAPManagement。 它解释了如何在没有 ReportViewer 控件的情况下使用 cookie 容器进行身份验证。

    【讨论】:

      【解决方案2】:

      我认为这行不通。 Azure 报告使用 Forms 身份验证,据我了解,您将无法将 Forms Auth cookie 与 MachineKey 进行匹配以进行加密。

      【讨论】:

      • 那么有没有其他方法可以在没有报告查看器且不引用报告服务的情况下检索代码中的 pdf?如果我有完整的 URL、用户名和密码,肯定有办法进行身份验证。如果可以手动完成,一定有办法以编程方式完成?
      【解决方案3】:

      我试图完成相同的任务..但使用 WebRequest 是不可能的。 我使用这样的 ServerReport 类更改了方法:

      ServerReport report;
      report = new ServerReport();
      report.ReportServerUrl = new Uri(reportServerName + "/ReportServer");
      report.ReportPath = "/ReportPath";
      report.ReportServerCredentials = new ReportServerCredentials();
      report.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("param1", param1));
      report.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("param2", param1));
      return report.Render(reportParams.OutputFormat);
      

      ReportServerCredentials 类必须实现 IReportServerCredentials 接口,如 this

      有关 IReportServerCredentials 接口和实现here 的更多信息。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-12-26
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多