【发布时间】:2013-09-19 20:40:12
【问题描述】:
我尝试通过基于 AD 的登录系统来保护我的 WCF 服务。我创建了一个名为“TestUsers”的 AD 组。我的用户帐户是该组的成员。 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>
IService1.cs(服务接口): 只有一种方法:
string GetWelcomeMessage();
Service1.svc.cs:
public class Service1 : IService1
{
[PrincipalPermission(SecurityAction.Demand, Role = @"mydomain\TestUsers")]
public string GetWelcomeMessage()
{
return "hello world";
}
}
有什么想法吗???
任何帮助将不胜感激。
【问题讨论】: