wcf net.tcp自行托管服务,获取“该服务不允许您匿名登录”

问题描述

我有一个带有net.tcp绑定的Windows Server中托管的WCF服务。 IIS中托管的Web API应用程序(ASP.NET MVC .NET 4.5.2)在使用httpcontext.user上下文模拟后,正在使用Windows身份验证调用此服务。 Web API和WCF服务都托管在同一域中的不同计算机中。 如果我尝试从Web服务器计算机上使用WebAPI,则一切正常。

但是,如果我们尝试从另一台计算机访问WebAPI,则在WFC服务器计算机的WCF跟踪日志中会出现以下错误

例外

System.IdentityModel.Tokens.SecurityTokenValidationException,System.IdentityModel,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089
The service does not allow you to log on anonymously.

堆栈跟踪:

System.ServiceModel.Security.SecurityUtils.ValidateAnonymityConstraint(WindowsIdentity identity,Boolean allowUnauthenticatedCallers)
System.ServiceModel.Channels.WindowsstreamSecurityUpgradeProvider.WindowsstreamSecurityUpgradeAcceptor.CreateClientSecurity(NegotiateStream negotiateStream,Boolean extractGroupsForWindowsAccounts)
System.ServiceModel.Channels.WindowsstreamSecurityUpgradeProvider.WindowsstreamSecurityUpgradeAcceptor.OnAcceptUpgrade(Stream stream,SecurityMessageProperty& remoteSecurity)
System.ServiceModel.Channels.StreamSecurityUpgradeAcceptorBase.AcceptUpgrade(Stream stream)
System.ServiceModel.Channels.InitialServerConnectionReader.UpgradeConnection(IConnection connection,StreamUpgradeAcceptor upgradeAcceptor,TimeSpan openTimeout,IDefaultCommunicationTimeouts defaultTimeouts)
System.ServiceModel.Channels.ServerSessionPreambleConnectionReader.ServerFramingDuplexSessionChannel.Onopen(TimeSpan timeout)
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
System.ServiceModel.Channels.CommunicationObject.open()
System.ServiceModel.dispatcher.ChannelHandler.OpenAndEnsurePump()
System.ServiceModel.dispatcher.ChannelHandler.OpenAndEnsurePump(Object state)
System.Runtime.ActionItem.DefaultActionItem.TraceAndInvoke()
System.Runtime.ActionItem.DefaultActionItem.Invoke()
System.Runtime.ActionItem.CallbackHelper.InvokeWithoutContext(Object state)
System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode,UInt32 numBytes,NativeOverlapped* nativeOverlapped)
System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error,UInt32 bytesRead,NativeOverlapped* nativeOverlapped)
System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode,NativeOverlapped* pOVERLAP)

有人遇到过类似的问题吗?非常感谢您的帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)