2011-01-24 29 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