【问题标题】:Is it possible to avoid specifying servicePrincipalName if both client and service are running under the same account on the same server?如果客户端和服务都在同一台服务器上的同一帐户下运行,是否可以避免指定 servicePrincipalName?
【发布时间】:2012-06-23 08:58:47
【问题描述】:

我有一个配置了 net.tcp 绑定的 WCF 服务:

<netTcpBinding>
    <binding >
        <security mode="Transport">
            <transport clientCredentialType="Windows" />
            <message clientCredentialType="None" />
        </security>
    </binding>
</netTcpBinding>

我有一个客户端 - Web 应用程序。两者都在同一台服务器上的 NT AUTHORITY\NETWORK SERVICE 下运行,只是端口不同。

当客户端尝试连接到服务时,会产生错误:

System.ComponentModel.Win32Exception:登录尝试失败

这可以通过在客户端指定 servicePrincipalName 来解决:

<endpoint>
    <identity>
        <servicePrincipalName value="NT AUTHORITY\NETWORK SERVICE" />
    </identity>
</endpoint>

但是我可以避免吗?我希望客户端使用其当前用户。

【问题讨论】:

    标签: .net wcf exception-handling wcf-security net.tcp


    【解决方案1】:

    客户端配置的 servicePrincipalName 值 int endpoint/identity 部分没有指定客户端的身份,而是指定了预期的服务身份。请记住,WCF 身份验证是相互的(客户端也识别服务)

    在这种情况下,客户端希望服务在“网络服务”帐户下运行。

    <endpoint>
        <identity>
            <servicePrincipalName value="NT AUTHORITY\NETWORK SERVICE" />
        </identity>
    </endpoint>
    

    如果客户端和服务位于同一台机器上,则可以替换为

    <endpoint>
        <identity>
            <servicePrincipalName value="host/localhost" />
        </identity>
    </endpoint>
    

    服务身份验证现在取决于 dns 名称 (localhost)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-21
      • 1970-01-01
      • 2012-10-07
      • 2023-03-18
      • 2017-06-01
      • 2021-02-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多