我和我的团队正在开发一个相当大的应用程序,其中包含许多基于 WCF NetTCP 的服务。此系统将在其下运行的 Windows 服务不是本地帐户,而是标准域用户(在托管服务的服务器上具有管理员权限)。在测试连接性的过程中,我遇到了 SSPI 调用失败的问题。基于几个小时的研究,这导致我在客户端配置中丢失了以下行:
<identity>
<userPrincipalName value="MACHINE\user" />
</identity>
使用它的问题是我不使用 VS 或 svcutil 为该服务生成客户端/代理 - 正在使用的代理完全用代码编写,并且它们继承 System.ServiceModel.ClientBase。我相信选择此选项的最初原因是我们可以使用完全相同的 DataMember 对象,这些对象通过围栏两侧的服务 - 第三方组不需要连接到我们的服务,所以这不是问题.
当我没有在标准 system.serviceModel 配置部分指定端点时,有谁知道我在客户端(代码或通过配置)中设置 userPrincipalName 的方法?
这是我的客户端 web.config 的外观以供参考:
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true" logMalformedMessages="true"
logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<behaviors>
<serviceBehaviors>
<behavior name="includeExceptions">
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_Default" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="Infinite" sendTimeout="01:00:00" portSharingEnabled="true" transferMode="Buffered" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
</security>
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>