【问题标题】:Security Exception in WCF service on Windows 2003 ServerWindows 2003 Server 上 WCF 服务中的安全异常
【发布时间】:2023-03-20 20:30:01
【问题描述】:

我在 Windows 2003 Server 中托管一个简单的 WCF 服务时遇到问题。我使用的是 netTcpBinding,默认情况下,它使用的是 Windows 身份验证。

客户端在另一台服务器上运行,并被 Windows 系统进程调用以将一些简单信息传回服务。安全上下文应该被传递回服务,并且客户端身份应该是 NT AUTHORITY\SYSTEM。

所有这些都在 Windows 2008 Server(和 Windows 7 FWIW)上运行得很好。然而,同样的配置在 Windows 2003 Server R2, SP 2 上失败了。我打开了 WCF 跟踪并在服务端看到了这个异常:

SecurityTokenValidationException: 该服务不允许您匿名登录

所以看起来在 Windows 2003 上,安全上下文没有被传递。

我在 SO 和 MS Support 中发现了一些类似的问题,但似乎大多数都围绕 IIS 问题;此服务在 Windows 服务中自托管,不涉及 IIS。

编辑:刚刚发现这是一个问题当客户端被 Windows 系统进程调用时。我可以交互地运行服务客户端(它只是一个控制台应用程序)并且运行良好。

有什么想法吗?

这是主机 WCF 配置:

<service name="MyService">
    <endpoint 
        address="" 
        binding="netTcpBinding" 
        bindingConfiguration="" 
        contract="IMyService">
        <identity>
            <dns value="localhost" />
        </identity>
    </endpoint>
    <host>
        <baseAddresses>
            <add baseAddress="net.tcp://TheAppServer:8732/MyService/" />
        </baseAddresses>
    </host>
</service>

这是客户端配置:

<system.serviceModel>
<bindings>
    <netTcpBinding>
        <binding 
            name="NetTcpBinding_IMyService" 
            transactionFlow="false" 
            transferMode="Buffered" 
            transactionProtocol="OleTransactions" 
            hostNameComparisonMode="StrongWildcard">
            <reliableSession 
                ordered="true" 
                inactivityTimeout="00:10:00" 
                enabled="false"/>
            <security mode="Transport">
                <transport 
                    clientCredentialType="Windows" 
                    protectionLevel="EncryptAndSign"/>
                <message 
                    clientCredentialType="Windows"/>
            </security>
        </binding>
    </netTcpBinding>
</bindings>
<client>
    <endpoint 
        address="net.tcp://TheAppServer:8732/MyService/" 
        binding="netTcpBinding" 
        bindingConfiguration="NetTcpBinding_IMyService" 
        contract="IMyService" 
        name="NetTcpBinding_IMyService">
        <identity>
            <dns value="localhost"/>
        </identity>
    </endpoint>
</client>

【问题讨论】:

  • 我相信您需要在服务器端重新创建相同的绑定配置,并确保服务器端的端点正在使用该绑定配置(具有传输安全性)
  • 您可以在服务器端创建相同的绑定,根据您列出的异常,我认为客户端没有将凭据发送到服务器端,您可以检查一下吗?
  • 刚刚添加了一个重要的编辑:如果我从桌面交互地执行客户端,这个配置就可以正常工作

标签: wcf security


【解决方案1】:

我认为您不能在 windows 2003 中托管 net.tcp

【讨论】:

    猜你喜欢
    • 2011-07-19
    • 1970-01-01
    • 2010-12-06
    • 1970-01-01
    • 2011-04-19
    • 1970-01-01
    • 2016-03-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多