C# WCF Active Directory授权-PrincipalPermission->;拒绝访问

C# WCF Active Directory授权-PrincipalPermission->;拒绝访问,c#,wcf,iis,C#,Wcf,Iis,我试图通过基于广告的登录系统来保护我的WCF服务。我创建了一个名为“TestUsers”的广告组。我的用户帐户是该组的成员。WCF服务托管在IIS中 但我总是得到异常“SecurityAccessDeniedException” 我的WCF服务看起来像: Web.Config <?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <add key="aspn

我试图通过基于广告的登录系统来保护我的WCF服务。我创建了一个名为“TestUsers”的广告组。我的用户帐户是该组的成员。WCF服务托管在IIS中

但我总是得到异常“SecurityAccessDeniedException”

我的WCF服务看起来像:

Web.Config

<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpEndpointBinding">
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <directoryBrowse enabled="true"/>
  </system.webServer>

</configuration>
Service1.svc.cs:

public class Service1 : IService1
    {
        [PrincipalPermission(SecurityAction.Demand, Role = @"mydomain\TestUsers")]
        public string GetWelcomeMessage()
        {
            return "hello world";
        }
    }
你知道怎么了吗


非常感谢您的帮助。

请确保运行承载IIS的服务的帐户被允许在AD中执行安全检查

也改变

includeExceptionDetailInFaults="false"


现在,这可能有助于您分析问题。

感谢您的回复Florian。允许运行服务的帐户执行安全检查。我已将includeExceptionDetailInFaults更改为true。但是没有其他信息。删除属性时,代码是否有效?您还可以通过删除属性并检查ServiceSecurityContext.Current.WindowsIdentity来验证绑定。当然,代码在没有“[PrincipalPermission(SecurityAction.Demand,Role=@“mydomain\TestUsers”)]”的情况下也可以工作。只需问:)ServiceSecurityContext.Current.WindowsIdentity的值是多少?;)在消费应用程序中?ServiceSecurityContext.Current为NULL mhhhhh
includeExceptionDetailInFaults="false"
includeExceptionDetailInFaults="true"