开发者

How to restrict users that consume WCF services

开发者 https://www.devze.com 2023-01-26 16:49 出处:网络
I have a WCF service that must be called by some Active Directory user. How can I restrict the allowed callers for tha开发者_StackOverflowt WCF service to a specific AD group?Since you appear to be u

I have a WCF service that must be called by some Active Directory user.

How can I restrict the allowed callers for tha开发者_StackOverflowt WCF service to a specific AD group?


Since you appear to be using Windows authentication, you will be able to use the Active Directory groups and membership of your users inside those groups to restrict the usage of service methods.

With this, you can then use declarative syntax to limit callers to certain groups:

[ServiceContract]
interface IMyService
{
   [OperationContract]
   [PrincipalPermission(SecurityAction.Demand, Role="YourCustomRole")]
   public string MethodLimitedToGroup(string someInput);
}

Anyone who is not member of that group you specified, and tries to call this method, will receive a SecurityException - but nothing else.

Is that what you're looking for?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号