问题描述
我有一个 .Net Core 3.1 应用程序,它试图通过 WCF 连接到 sql Server 报表服务器,以便以编程方式按需生成报表。
但该程序无法对报表服务器进行身份验证。
这是相关的程序代码:
var binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
binding.MaxReceivedMessageSize = 10485760; //10MB limit
// Create the execution service SOAP Client
var rsExec = new ReportExecutionServiceSoapClient(
binding,new EndpointAddress("http://my-ssrs/reportserver")
);
// Setup access credentials.
var clientCredentials = new NetworkCredential(
"MyreportserverUserName","MyreportserverPassword","."
);
if (rsExec.ClientCredentials != null)
{
rsExec.ClientCredentials.Windows.AllowedImpersonationLevel =
System.Security.Principal.TokenImpersonationLevel.Impersonation;
rsExec.ClientCredentials.Windows.ClientCredential = clientCredentials;
}
// ************************************************
// Get following Exception when next line executes.
// ************************************************
await rsExec.LoadReportAsync(null,"/path-to/my-report",null);
当执行最后一行(“rsExec.LoadReportAsync”)时,出现以下异常:
The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication header received from the server was 'NTLM'.
报表服务器位于同一个 Windows 域中。
经过一番研究,我尝试更改 ClientCredentialType = HttpClientCredentialType.Windows 但这产生了不同的异常,如下所示:
The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'NTLM'.
有人对我可以尝试的方法有什么建议吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)