微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决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 举报,一经查实,本站将立刻删除。