21

我有一个带有 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)

尝试搜索解决方案,但没有找到符合我要求的解决方案,因此在此处发布。

可能是什么问题呢?

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

<security mode="None"></security>

我得到另一个错误:

错误:套接字连接被中止。这可能是由于处理您的消息时出错或远程主机超出接收超时,或者是潜在的网络资源问题造成的。本地套接字超时为“00:00:59.5149722”。

4

7 回答 7

28

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

注意安全节点。

<bindings>
  <netTcpBinding>
    <binding name="customTcpBinding" maxReceivedMessageSize="20480000" transferMode="Streamed" >
      <security mode="None"></security>
    </binding>
  </netTcpBinding>
</bindings>
于 2012-01-13T03:01:16.163 回答
6

该错误是 TokenImpersonation 错误。

似乎正在发生的事情是调用进来,服务器端的一些代码要求用户被服务器代码模拟。

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

您有 2 个基本选项:

  • 在允许模拟另一个用户的用户的安全上下文中运行服务
  • 重写您的应用程序,以便不需要模拟
于 2011-12-31T15:39:53.837 回答
4

我知道这已经得到了“关闭安全性”的回答。但万一有人感兴趣,我确实设法在一个内部网环境中使用 NetTcpBinding 获得 WCF 传输 Windows 身份验证,这在经历了很大的痛苦之后自己工作。

本质上它归结为使用此配置:

<security mode="Transport">
  <transport clientCredentialType="Windows" />
</security>

您可以在博客文章WCF 传输 Windows 身份验证在 Intranet 环境中使用 NetTcpBinding 中查看更多详细信息。

于 2012-02-16T09:24:38.383 回答
2

我们的应用程序是基于 Windows 的应用程序,连接到本地 Intranet 中的 WCF 服务。安全级别已设置为 Windows 身份验证。我们偶尔会收到此错误。经过调查,我们发现 Windows 密码已过期。修改密码后一切正常...

如果您偶尔收到此错误,这是一个简单的检查。

于 2013-06-05T10:10:04.647 回答
1

似乎客户端请求未在服务器上进行身份验证。您可以在此处此处找到有用的信息。

于 2012-01-10T08:31:26.567 回答
0

当您尝试从服务中抽取过多数据时,通常会出现“Socket connection was aborted”的第二个错误。

我建议先模拟用户以使凭据正常工作,然后再考虑问题的提醒。

您可以在How to: Impersonate a Client on a Service中找到有关模拟的一些有用信息。

于 2012-01-16T05:38:37.487 回答
0

与@vonbalaji 类似,当帐户由于多次错误输入密码而被锁定时,我已经看到了这种情况。

于 2018-09-26T12:15:54.290 回答