My ASP.Net Core 3.1 App programmatically generates reports on SSRS. I've added a Connected Service reference to the SSRS web service in my app.
The App basically builds RDL and sends the RDL over to the SSRS Service using the service reference. The RDL contains an SQL query that's used to pull the data for the report.
The Problem is the SQL Server is returning an error - Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON' - here's the entire error message from the SSRS service:
Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: Cannot create a connection to data source 'MyDataSource'. ---> System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\\ANONYMOUS LOGON'
Here's the code snippet:
using System.ServiceModel;
using System;
var binding = new BasicHttpBinding();
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows; // tried with 'Ntml' also didn't work
var endpointAddress = new System.ServiceModel.EndpointAddress(ssrsUrl);
using(var proxy = new ReportExecutionServiceSoapClient(binding, endpointAddress))
{
var trustedUser = new TrustedUserHeader();
var loadRequest = new LoadReportDefinition2Request(trustedUser, rdl);
var loadResponse = await proxy.LoadReportDefinition2Async(loadRequest);
var deviceInfo = DeviceInfo(request.RenderOptions.CsvExcelMode);
var renderRequest = new Render2Request(loadResponse.ExecutionHeader, trustedUser, format, deviceInfo, PageCountMode.Estimate);
var renderResponse = await proxy.Render2Async(renderRequest);
result = renderResponse.Result;
}