如何获得serviceCredentials> windowsAuthentication> allowAnonymousLogons在WCF中工作?

时间:2013-05-24 11:39:54

标签: wcf wcf-authentication

我有一个作为netTcpBinding公开的WCF服务。

在服务方面:

<netTcpBinding>             
    <binding> 
      <security mode="Message">
        <message clientCredentialType="Windows"/>
      </security>         
    </binding>
</netTcpBinding> ...
// Service behavior
<behavior>         
    <serviceCredentials>
       <windowsAuthentication allowAnonymousLogons="true" />
     </serviceCredentials>          
</behavior>

我无法从另一台计算机上的匿名用户访问此服务。 (错误:无法验证协商失败的重新订阅。)

什么是

<windowsAuthentication allowAnonymousLogons="true" /> 

办?

我希望通过net tcp绑定可以访问Windows和匿名用户的服务。我可以使用UserName验证来执行此操作,但如何使用Windows身份验证执行此操作?

由于

2 个答案:

答案 0 :(得分:3)

您是否在客户端上设置了AllowedImpersonationLevel?

<behaviors>
    <endpointBehaviors>
      <behavior>
        <clientCredentials>
          <windows allowedImpersonationLevel="Anonymous"/>
        </clientCredentials>
      </behavior>
    </endpointBehaviors>
</behaviors>

client.ClientCredentials.Windows.AllowedImpersonationLevel = 
System.Security.Principal.TokenImpersonationLevel.Anonymous;

答案 1 :(得分:0)

MSDN文章Debugging Windows Authentication Errors指出需要将您的服务配置与@ user1467261提到的客户端配置相结合。它指出了另一篇关于WCF模仿的文章,以获得更多细节 - 但是对它进行掩饰,结合这些设置的需求并不是很明显。

相关问题