繁体   English   中英

连接到WCF服务时客户端无法进行身份验证

[英]Client unable to authenticate when connecting to WCF service

我在Windows服务中托管了WCF服务。 该应用程序是Intranet应用程序,我已通过编程方式将服务和客户端上的绑定设置为:

NetTcpBinding aBinding = new NetTcpBinding(SecurityMode.Transport);
aBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
aBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign;

服务和客户端都具有配置有SPN的端点:

EndpointAddress = new EndpointAddress(uri, EndpointIdentity.CreateSpnIdentity("Service1"));

据我所知,我已经正确设置了绑定-通常我可以正常连接到服务。 但是,我确实遇到了这样一种情况:在运行Windows Server 2003 R2,x64,SP2的服务器上,当客户端尝试连接时,我立即收到以下异常:

INNEREXCEPTION-异常消息:

InvalidCredentialException:目标名称不正确或服务器已拒绝客户端凭据。

堆栈跟踪:

at System.Net.Security.NegoState.ProcessAuthentication(LazyAsyncResult lazyResult)
   at System.Net.Security.NegotiateStream.AuthenticateAsClient(NetworkCredential credential, String targetName, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel allowedImpersonationLevel)
   at System.ServiceModel.Channels.WindowsStreamSecurityUpgradeProvider.WindowsStreamSecurityUpgradeInitiator.OnInitiateUpgrade(Stream stream, SecurityMessageProperty& remoteSecurity)

当我尝试从域中的另一台计算机连接到服务时,出现异常,但是如果我在运行该服务的同一台计算机上连接到服务,则可以正常工作。

托管服务本身以域用户帐户身份运行-但我尝试将服务作为本地系统和网络服务运行均无济于事。 我已经检查了服务器的本地安全策略,但没有发现任何问题(即“从网络访问此计算机”包括“所有人”)。

任何人都有什么解决办法的想法?

我想知道是否需要在Active Directory中针对服务的SPN做些事情? 我已经阅读了一些有关使用setspn.exe来注册或刷新SPN的信息,但是我以前不需要这样做。 为什么这可以与其他配置一起使用,但不能与上面的配置一起使用?

尝试以具有本地管理员访问权限的帐户运行该服务-如果您不能在如此大的权限范围内运行该服务,那么我相信您需要使用您所暗示的setpn.exe。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM