Silverlight-如何使用windows身份验证从客户端使用WCF服务

Silverlight-如何使用windows身份验证从客户端使用WCF服务,silverlight,wcf,windows-authentication,Silverlight,Wcf,Windows Authentication,我有一个silverlight 4应用程序,我需要客户端使用由SSL保护并使用windows身份验证的WCF服务。只有特定active directory组的成员才能调用WCF服务 这是我的web.config。使用当前配置,任何人都可以调用WCF服务。正确的值应该是什么 谢谢, 克鲁维 以下文章介绍了如何使用Windows auth为Silverlight客户端保护WCF服务: 本文讨论如何使用PrincipalPermissionAttribute,它将允许您限制组可以调用特定的服务操作:

我有一个silverlight 4应用程序,我需要客户端使用由SSL保护并使用windows身份验证的WCF服务。只有特定active directory组的成员才能调用WCF服务

这是我的web.config。使用当前配置,任何人都可以调用WCF服务。正确的值应该是什么

谢谢, 克鲁维


以下文章介绍了如何使用Windows auth为Silverlight客户端保护WCF服务:

本文讨论如何使用PrincipalPermissionAttribute,它将允许您限制组可以调用特定的服务操作:


谢谢,它很管用。有没有一种不用编码,只配置web.config的方法?目前我必须对角色进行硬编码:[PrincipalPermission(SecurityAction.Demand,role=“ZCUsers”)]有没有办法避免这种情况?
<configuration>

  <system.diagnostics>

  </system.diagnostics>



  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <customErrors mode="On" defaultRedirect="~\Errors\Error.htm">
      <error statusCode="404" redirect="~\Errors\404.htm"/>
    </customErrors>
  </system.web>

  <connectionStrings>

  </connectionStrings>

  <system.serviceModel>

    <diagnostics>

    </diagnostics>


    <extensions>
      <behaviorExtensions>
        <add name="silverlightFaults"
             type="ZCUtils.SilverlightFaultBehavior, ZCUtils, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
      </behaviorExtensions>
    </extensions>

    <behaviors>
      <endpointBehaviors>
        <behavior name="SilverlightFaultBehavior">
          <silverlightFaults />
        </behavior>
      </endpointBehaviors>

      <serviceBehaviors>
        <behavior name="ZCBehavior">
          <serviceMetadata httpsGetEnabled="true" />          
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>

    </behaviors>

    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBindingSsl" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
          <security mode="Transport" />
        </binding>
      </basicHttpBinding>        
    </bindings>

    <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" />

    <services>
      <service name="ZC.Web.Services.ZCServices" behaviorConfiguration="ZCBehavior">
        <endpoint address="" behaviorConfiguration="SilverlightFaultBehavior"
          binding="basicHttpBinding" bindingConfiguration="BasicHttpBindingSsl"
          contract="ZC.Web.Services.ZCServices" />
      </service>
    </services>

  </system.serviceModel>
</configuration>