如何使用自定义身份验证扩展连接到SSRS API

时间:2015-04-18 18:13:28

标签: c# .net visual-studio-2012 reporting-services ssrs-2012

我之前已经设置了一个应用程序,通过ReportExecutionServiceSoapClient连接到SSRS并运行报告,但是由于实现了自定义安全扩展,我无法再连接。这是我一直在尝试的。我一直有500个错误。我可以很好地登录报告管理器,但API不起作用。

ReportExecution.ReportExecutionServiceSoapClient rsExec = new ReportExecution.ReportExecutionServiceSoapClient();

        rsExec.ClientCredentials.UserName.UserName = "username";
        rsExec.ClientCredentials.UserName.Password = "password";
        byte[] results = null;
        TrustedUserHeader trusteduserHeader = new TrustedUserHeader();
        ExecutionInfo execInfo = new ExecutionInfo();
        ExecutionHeader execHeader = new ExecutionHeader();

        // Load the report
        string reportPath = selReport.Path;
        string historyID = null;
        ServerInfoHeader serviceInfo = new ServerInfoHeader();
        rsExec.LoadReport(trusteduserHeader, reportPath, historyID, out serviceInfo, out execInfo);

这是我的Web.config

  <system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="ReportingService2010Soap" />
    <binding name="ReportExecutionServiceSoap" />
  </basicHttpBinding>
</bindings>
<client>
  <endpoint address="REMOVED/ReportServer/ReportExecution2005.asmx"
    binding="basicHttpBinding" bindingConfiguration="ReportExecutionServiceSoap"
    contract="ReportExecution.ReportExecutionServiceSoap" name="ReportExecutionServiceSoap" />
  <endpoint address="REMOVED/ReportServer/ReportService2010.asmx"
    binding="basicHttpBinding" bindingConfiguration="ReportingService2010Soap"
    contract="ReportService.ReportingService2010Soap" name="ReportingService2010Soap" />
</client>

&#34; {&#34;远程服务器返回错误:(500)内部服务器错误。&#34;}&#34;

loadreport调用发生此错误。唯一阻止它工作的是认证。我添加了两行用户名和密码并删除了这些行

  rsExec.ClientCredentials.Windows.ClientCredential = (System.Net.NetworkCredential)System.Net.CredentialCache.DefaultCredentials;
        rsExec.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

您是否可以使用自定义身份验证连接到API?这是我更改SSRS以执行自定义身份验证的方式 http://www.codeproject.com/Articles/675943/SSRS-Forms-Authentication

非常感谢任何帮助。我一直在谷歌上搜索。

1 个答案:

答案 0 :(得分:0)

这对我有用:

System.Net.NetworkCredential clientCredentials = new System.Net.NetworkCredential(ReportServerUserName, ReportServerPassword);
rsExec.Credentials = clientCredentials;