开发者

SSRS DataSourceCredentials and Windows Authentication

开发者 https://www.devze.com 2023-01-31 01:06 出处:网络
I have an application where I am rendering a SSRS report via the SOAP Web Service.What I am attempting to do is to pass the credentials to the ReportExecutionService that will be used by the datasourc

I have an application where I am rendering a SSRS report via the SOAP Web Service. What I am attempting to do is to pass the credentials to the ReportExecutionService that will be used by the datasource for the database access.

This is currently working using SQL Authentication. What I am trying to figure out is how to get this working for a user that is configured for the database using Windows Authentication. The user account is a domain user account, and I added this user to the database and to the db_owner role.

When I pass the credentials for a Windows User account and run SQL Profiler I get the following error message:

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

The following code is the (abbreviated) code that is working when passing the credentials for a SQL User, but failing with the above message when passing the domain user credentials:

public static byte[] RunReport(stri开发者_高级运维ng 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);
        }

Note that I added the ReportUserDomain parameter to the DataSourceCredentials to try to get this to work for Windows Auth, the code that is currently working for SQL Authentication does not include this variable.

Any help is greatly appreciated.


I was unable to figure out a way of passing Windows User Credentials via the DataSourceCredentials object and authenticate against SQL Server. It seems that this functionality only supports SQL Server authentication.

What I ended up doing to solve the problem was to set the Data Source on all of the reports to "Use Windows Authentication (integrated security)" instead of "prompt for credentials". I then pass the DefaultCredentials from the CredentialCache to the ReportExecutionService, which essentially passes the credentials for the Windows User that the AppPool is running under. I then granted access to the database and SSRS for this Windows User Account, and things are working as expected.

This, unfortunately, does not account for the scenario of using the credentials for a Windows User account separate from the AppPool account. For instance, a user account that is used exclusively for reporting purposes. Despite this, the solution is suitable for my needs.

0

精彩评论

暂无评论...
验证码 换一张
取 消