我有一个用C#客户端应用程序消费WCF Web服务。 我也有存储在Active Directory 4组。 客户端应用程序传递用户凭据连接该Web服务。
Web服务暴露多个API或方法来通过客户端应用程序如下访问:
[OperationContract]
bool Read();
[OperationContract]
bool Write();
阅读()方法应该是所有客户端访问
Write()方法只能由用户那些属于specifc由Active Directory维护Windows用户组可以访问。
问:我们如何可以过滤或限制客户端基于其用户群暴露接口或方法维持AD?
jrista,感谢您的回复。 我想同样的指令作为的PrincipalPermission如下:
[PrincipalPermission(SecurityAction.Demand, Role = "Readers")]
[OperationContract]
bool Read();
[PrincipalPermission(SecurityAction.Demand, Role = "Writers")]
[OperationContract]
bool Write();
但是,这是行不通的。 阅读组用户也能够调用作家()方法和作家群体的用户也能够调用Write()方法。
有一两件事我想告诉你的是,我在我的web.config文件中使用BasicHttpBind如下:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBind">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="DXDirectory.DXDirectoryService" behaviorConfiguration="DXDirectory.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBind"
name="BasicBinding" contract="DXDirectory.IDXDirectoryService">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DXDirectory.Service1Behavior">
<!-- 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" />
<serviceAuthorization principalPermissionMode="UseWindowsGroups"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
它是实现此功能的wsHttpBinding要求? 如果是的话,那我怎么才能在我的Web服务实现的wsHttpBinding?