【发布时间】:2022-03-12 07:05:42
【问题描述】:
我正在尝试在 .NET Core 中执行 SSRS 报告。
由于 .NET Core 不允许您添加服务引用,因此您必须使用 WCF 连接服务来添加对 WSDL 的引用,以便它可以生成与 .NET Core 兼容的代码。这就是我为 ReportExecution2005.asmx 所做的(如果重要,可以使用 SQL Server 2016)。
我尝试使用以下方法对服务进行身份验证:
var rsExec = new ReportExecutionServiceSoapClient(ReportExecutionServiceSoapClient.EndpointConfiguration.ReportExecutionServiceSoap,
new EndpointAddress("http://server/ReportServer/ReportExecution2005.asmx"))
{
ClientCredentials =
{
Windows =
{
AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation,
ClientCredential = new NetworkCredential("username", "password")
}
}
};
还尝试设置用户名对象而不是 Windows 对象,但无论哪种方式结果都是以下错误:
MessageSecurityException:HTTP 请求未经客户端身份验证方案“匿名”授权。从服务器收到的身份验证标头是“NTLM”。
查看 Fiddler,代码没有传递凭据。
这是从 WSDL 生成的代码
public ReportExecutionServiceSoapClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress)
: base(ReportExecutionServiceSoapClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress)
{
this.Endpoint.Name = endpointConfiguration.ToString();
ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
}
static partial void ConfigureEndpoint(System.ServiceModel.Description.ServiceEndpoint serviceEndpoint, System.ServiceModel.Description.ClientCredentials clientCredentials);
我可能弄错了,但这不是在设置 ClientCredentials 对象之前使用 ClientCredentials 对象调用私有方法 ConfigureEndpoint 吗?
我没有看到任何其他方式来配置 ClientCredentials 或调用 ConfigureEndpoint,那么您应该如何进行身份验证?其他构造函数基本上是相同的,除了一个接受 Binding 而不是 EndpointConfiguration 的构造函数。有什么想法吗?
【问题讨论】:
-
另外,我知道我可以将它放入 .NET Framework 库并从那里引用它,但我想尝试使用 .NET Core 让它工作。
-
您的安全模型是如何设置的?您是否在 ssrs 实例上使用本地用户向 ssrs 请求?如果是,该用户是否有权这样做?
-
另一件事是检查您的 wfc 绑定的传输安全配置。
-
@RossBush,是有权限的本地账号。我在 .NET 4.6 和等效代码下使用相同的凭据测试了该服务,并且能够毫无问题地执行报告。至于 WCF 绑定,恐怕我实际上对此并不了解。我没有修改服务器本身的任何东西,几乎只是使用默认选项安装了 SSRS。
标签: c# web-services reporting-services .net-core