簡體   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