1
我上一个帖子,您可以使用ASP.Net授权在网络配置来控制访问一个WCF Web服务,以取代以下属性阅读:无法设定授权规则在web.config中的WCF服务
[PrincipalPermission(SecurityAction.Demand, Role="Administrators")]
测试我一直在使用“管理员”这是一个有效的角色,所以应该允许我访问和“测试”这是没有。
<authentication mode="Windows" />
<authorization>
<allow roles=".\TEST"/>
<deny roles="*"/>
</authorization>
它仍然可以让我访问:使用上述属性时,但是当我评论说出来,在我的web.config文件中使用此这工作得很好。
所以我想知道如果我刚刚在web.config中出现了错误,或者我读的是否错误地说使用它。
仅供参考,这是我看着帖子:
Using Windows Role authentication in the App.config with WCF
和下面是我的web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Windows" />
<authorization>
<allow roles=".\TEST"/>
<deny users="*"/>
</authorization>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpEndpointBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="WcfService1.ServiceBehaviour1" name="WcfService1.Service1">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpEndpointBinding"
name="BasicHttpEndpoint" contract="WcfService1.IService1">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfService1.ServiceBehaviour1">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
感谢。
英雄。祝你好运先生。 – warbi 2013-10-16 10:08:15