2010-12-16 89 views
0

我有一個應用程序,通過SOAP Web服務呈現SSRS報告。我試圖做的是將憑據傳遞給將由數據源用於數據庫訪問的ReportExecutionService。SSRS DataSourceCredentials和Windows身份驗證

這是目前正在使用SQL身份驗證。我試圖弄清楚的是如何使用Windows身份驗證爲使用數據庫配置的用戶獲得此功能。用戶帳戶是一個域用戶帳戶,我將此用戶添加到數據庫和db_owner角色。

當我通過憑據的Windows用戶帳戶和運行SQL事件探查我收到以下錯誤信息:

Login failed for user 'ourdomain\User'. Reason: Attempting to use an NT account name with SQL Server Authentication. [CLIENT: <local machine>] 

下面的代碼是通過證書的時正在工作(略)代碼SQL用戶,但上述消息未能傳遞域用戶憑據時:

public static byte[] RunReport(string reportPath, List<ReportParameter> reportParameters, ReportOutputType outputType) 
     { 
      ReportExecutionService reportExecutionService = new ReportExecutionService(); 

      var creds = new DataSourceCredentials[1]; 

      creds[0] = new DataSourceCredentials() { DataSourceName = "DynamicDataSource", UserName = ReportUserDomain + @"\" + ReportUserAccount, Password = ReportUserPassword }; 

      reportExecutionService.LoadReport(reportPath, null); 

      reportExecutionService.SetExecutionCredentials(creds); 

      return reportExecutionService.Render(Enum.GetName(typeof(ReportOutputType), outputType), GetDeviceInfo(outputType), out extension, out mimetype, out encoding, out warning, out streamids); 
     } 

請注意,我說的ReportUserDomain參數的DataSourceCredentials,試圖讓這對Windows驗證工作,當前正在幹活的代碼g for SQL身份驗證不包含此變量。

任何幫助,非常感謝。

回答

3

我無法想出一種通過DataSourceCredentials對象傳遞Windows用戶憑據並通過SQL Server進行身份驗證的方法。看來這個功能只支持SQL Server身份驗證。

我最終解決的問題是將所有報告中的數據源設置爲「使用Windows身份驗證(集成安全性)」而不是「提示輸入憑據」。然後,我將DefaultCredentials從CredentialCache傳遞給ReportExecutionService,它本質上傳遞AppPool正在運行的Windows用戶的憑據。然後,我授予了此Windows用戶帳戶的數據庫和SSRS訪問權限,並且事情按預期工作。

不幸的是,這並沒有考慮使用與AppPool帳戶分開的Windows用戶帳戶的憑據的情況。例如,專門用於報告目的的用戶帳戶。儘管如此,該解決方案適合我的需求。