服务器已拒绝客户端凭据

Bra*_*avo 19 wcf net.tcp

我有一个带有net.tcp绑定的WCF服务,作为Windows服务托管在服务器上.我无法访问此服务.但是,当我在本地网络上托管它时,我能够这样做.

收到错误

消息:**服务器已拒绝客户端凭据.

内在例外:

System.Security.Authentication.InvalidCredentialException:
The server has rejected the client credentials.
---> System.ComponentModel.Win32Exception:
The logon attempt failed --- End of inner exception stack trace
--- at System.Net.Security.NegoState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.Security.NegotiateStream.AuthenticateAsClient(NetworkCredential credential, ChannelBinding binding, String targetName, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel allowedImpersonationLevel)
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)
Run Code Online (Sandbox Code Playgroud)

尝试搜索解决方案,但发现没有符合我的要求,因此发布在这里.

可能是什么问题呢?

如果我在客户端上将我的安全模式设置为"无"

<security mode="None"></security>
Run Code Online (Sandbox Code Playgroud)

我收到另一个错误:

错误:套接字连接已中止.这可能是由于处理消息的错误或远程主机超出接收超时或基础网络资源问题引起的.本地套接字超时为'00:00:59.5149722'.

spi*_*n_g 27

我只是遇到了同样的问题,试图让DMZ中的服务器与网络内的服务进行通信.为我修复它的解决方案是将以下内容添加到app.config:

请注意安全节点.

<bindings>
  <netTcpBinding>
    <binding name="customTcpBinding" maxReceivedMessageSize="20480000" transferMode="Streamed" >
      <security mode="None"></security>
    </binding>
  </netTcpBinding>
</bindings>
Run Code Online (Sandbox Code Playgroud)


Shi*_*iji 6

错误是TokenImpersonation错误.

似乎正在发生的是呼叫进入,服务器端的某些代码要求用户被服务器代码模拟.

服务器代码作为本地系统帐户运行,因此无法模拟域用户.

您有2个基本选项:

  • 在允许模拟其他用户的用户的安全上下文中运行该服务
  • 重写您的应用程序,以便不需要模拟