c# - 调用 WCF 服务时出现随机 AuthenticationManager CustomTargetNameDictionary 异常

标签 c# asp.net wcf web-services authentication

我在从 ASP.Net 应用程序调用 WCF 服务时收到此错误:

Unhandled Exception: System.InvalidOperationException

System.InvalidOperationException: The entry found in AuthenticationManager's CustomTargetNameDictionary for {URL} does not match the requested identity of host/{Hostname}.

Server stack trace: 
   at System.ServiceModel.Channels.HttpTransportSecurityHelpers.AddIdentityMapping(Uri via, EndpointAddress target)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.PrepareOpen()
   at System.ServiceModel.Channels.HttpsChannelFactory.HttpsRequestChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
   at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

奇怪的是,除了我们的生产网络服务器,我无法在任何机器上重现它,而且它只是偶尔发生。该服务需要事件目录身份验证,但我确信用户具有正确的权限集。

这似乎不是 WCF 配置的问题,因为它有时可以正常工作,并且其他应用程序可以毫无错误地调用同一服务。

我已经尝试完全重新创建用户,重新创建它运行的应用程序池并重新安装应用程序。感谢您的帮助!

最佳答案

这似乎与“损坏的模拟”的“旧”问题相匹配。 哪个部分或您的解决方案使用凭据运行? 如果您的 Web 用户(即使他已登录到您的域)在 ASP.net 应用程序中被正确模拟,您的链可能会在调用 WS(以及从那里调用 AD)时中断。因此,请确保您的 WS 在用户上下文中运行,并且允许它访问 AuthManager 部分。如果需要,请确保在用户帐户或计算机帐户上启用了 Kerberos 委派。

(在您的 PC 上开发时您可能看不到这个问题,因为您可能以管理员身份运行并具有“调试”权限。)

喂, 托马斯

关于c# - 调用 WCF 服务时出现随机 AuthenticationManager CustomTargetNameDictionary 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1244771/

相关文章:

c# - 响应状态码不表示成功 : 404 (Not Found) with owin library

c# - WCF 调用一个函数而不等待它完成它的工作?

.net - 如何在 WCF 调用的服务端获取用户名和密码?

asp.net - IE6 及更高版本上禁用按钮的前景色

c# - 模拟 ViewModel 以使用 Moq 进行单元测试?

c# 相当于 Java 中的 nextElement()

c# - 我应该在 n 层应用程序中测试哪一层

c# - 如何设置底层 Socket UDP 的缓冲区大小?

c# - C#.net 中的 XML 数据库

asp.net - ASP.Net WebAPI 中的自定义路由处理程序