【问题标题】:SSPI: user principle name WCF clientSSPI:用户主体名称 WCF 客户端
【发布时间】:2012-12-23 13:25:30
【问题描述】:

我正在尝试访问 wcf 客户端。我知道人们现在正在从中获取信息,所以我知道它有效。我的问题是我似乎无法克服它。该服务是相互认证的服务。我在本地计算机上的个人商店中有适当的证书。即使这样,我也会遇到以下异常:

 A call to SSPI failed, see inner exception

深入搜索异常,我看到了:

Message : The target principal name is incorrect

我该如何解决这个问题?我是否需要模拟运行应用程序池的用户?我是否需要添加 Identity\ServicePrincipleName 或 Identity\UserPrincipleName?有没有人遇到过类似的问题?

【问题讨论】:

    标签: wcf-client sspi


    【解决方案1】:

    为了供其他人将来参考,我遇到了这个问题,但现有的答案没有帮助。

    我的问题是 userPrincipalName 被用作服务参考。

    我最近重新注册了服务参考以便更新它,但它用我的电子邮件地址覆盖了日志文件中指定的userPrincipalName

    <endpoint address="net.pipe://localhost/XXXX"
      binding="netNamedPipeBinding" bindingConfiguration="NetNamedPipeBinding_IXXX"
      contract="XXXServiceReference.IXXX"
      name="NetNamedPipeBinding_IXXXX">
      <identity>
        <userPrincipalName value="my@emailaddress.com" />
      </identity>
    </endpoint>
    

    为了解决这个问题,我只是将userPrincipalName 更改为localhost,它是以前的:

    <userPrincipalName value="localhost" />
    

    【讨论】:

      【解决方案2】:

      对我来说,当我在端点中指定服务器的用户名时,它就起作用了。不是客户的用户名。它是 UPN,而不是 SPN。

      new EndpointAddress(
          new Uri("net.tcp://server:1234/MyWcf/svc"),
              EndpointIdentity.CreateUpnIdentity("username@domain.local"))
      

      据我了解,客户端验证它正在与预期用户交谈。

      【讨论】:

        【解决方案3】:

        我重新生成了客户端,并且 output.config 文件中的端点现在有了<identity> <userPrincipalName value="Serviecname@companyname.com" /> </identity> 在端点标签中。所以新的端点看起来像 -

         <endpoint address="net.tcp://machinename:6001/ReferenceDataService" binding="netTcpBinding" bindingConfiguration="netTcpBindingConf" contract="IReferenceDataService" >
             <identity>
         <userPrincipalName value="Serviecname@companyname.com" />
        

        这解决了我的问题

        【讨论】:

        • 如果有人不熟悉 WCF - 我使用 svcutil.exe 重新生成客户端,并使用它生成 output.config。
        【解决方案4】:

        在此处查看我对类似问题的回答:netTCP binding Soap Security Negotiation Failed。本指南应适用于其他绑定,而不仅仅是 TCP。

        【讨论】:

          猜你喜欢
          • 2016-03-04
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2020-01-11
          • 2013-07-14
          相关资源
          最近更新 更多