2011-01-24 32 views
0

我有一个SSRS(2008标准,而不是R2),所以我使用ReportExecution2005.asmx和ReportService2005.asmx来运行它们。尝试访问SQL Server报告服务的web服务时出现用户认证问题

我们开发了一个可以通过webservice连接到SSRS的应用程序。它在我们的测试服务器上运行良好,但是现在我试图在虚拟机上配置一个新的服务器,并且没有办法,每当应用程序尝试连接到SSRS Web服务时,我都会得到一个未受保护的401。

这很奇怪,因为如果我只将.asmx url放在客户端工作站上的firefox中,它会提示我输入用户名密码,我输入它并获得wsdl定义,所以我认为访问是正确的。

这里是我的代码:

public ReportGateway() 
    { 
     _rs = new ReportingService2005 { Credentials = new NetworkCredential(ConfigurationManager.AppSettings["ReportGatewayUser"], ConfigurationManager.AppSettings["ReportGatewayPassword"]) }; 
     _rs.Url = "http://MyMachine:80/ReportServer/ReportService2005.asmx";//?? I saw when I was debugging that it wasn't reading the value in the app.config, but keeping the url of the reference when I created it, so for my test of the moment, I hard-setted it 
     _rsExec = new ReportExecution2005.ReportExecutionService { Credentials = new NetworkCredential(ConfigurationManager.AppSettings["ReportGatewayUser"], ConfigurationManager.AppSettings["ReportGatewayPassword"]) }; 
     _rsExec.Url = "http://MyMachine:80/ReportServer/ReportExecution2005.asmx";//Same 
     GenerateReportList(); 
    } 
    [MethodImpl(MethodImplOptions.Synchronized)] 
    private void GenerateReportList() 
    { 
     try 
     { 
      Dictionary<String, SRSSReport> reports = new Dictionary<String, SRSSReport>(); 
      foreach (var children in _rs.ListChildren("/", true)) 
      { 
       if (children.Type == ItemTypeEnum.Report) 
       { 
        SRSSReport report = new SRSSReport {Name = children.Name, Path = children.Path}; 
        ReportParameter[] parameters = _rs.GetReportParameters(children.Path, null, false, null, null); 
        foreach (ReportParameter parameter in parameters) 
         report.Parameters.Add(new SRSSReportParameter {Name = parameter.Name, Type = _typeConverstion[parameter.Type]}); 
        reports.Add(report.Path, report); 
       } 
      } 
      lock (_lockObject) 
      { 
       _reports = reports; 
      } 
     }catch(Exception ex) 
     { 
      _reports = new Dictionary<string, SRSSReport>(); 
      Logger.Instance.Error("Error when contacting the reporting server", ex); 
     } 
    } 

我完全地绝望了,现在,我已经在天找了一个解决方案,我不知道有什么我可以做错了。

你有一个想法/解决方案/ ...来帮助我吗?

非常感谢你,任何帮助将非常感激。

回答

1

您需要调用SSRS Web服务的LogonUser方法。从Authentication in Reporting Services

对Reporting Services中的报表服务器进行身份验证的主要方法是LogonUser方法。 Reporting Services Web服务的此成员可用于将用户凭据传递给报表服务器进行验证。您的基础安全扩展实现IAuthenticationExtension.LogonUser,其中包含您的自定义身份验证代码。在表单身份验证示例中,LogonUser对数据库中提供的凭据和自定义用户存储执行身份验证检查。

如果您需要检查任何IIS问题,请检查Troubleshooting HTTP 401 errors in IIS

此外,您应该知道,当连接到希望使用身份验证的IIS站点时,您将首先得到一个401 Unauthorized错误,指出您需要提供凭据。 Web浏览器静静地吞下这些信息,然后提供当前的Windows凭据(例如IE)或提示您输入凭据(例如,Firefox,除非您已经调整过它自动显示它们)。

+0

我知道,其实我认为我做了一个糟糕的配置。我删除了SRSS的所有用户并重新设置了它,并且它正在工作 – J4N