2010-12-16 46 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用户帐户的凭据的情况。例如,专门用于报告目的的用户帐户。尽管如此,该解决方案适合我的需求。