How to do Role based authentication in WCF using Windows authentication (Active Directory)?
I have a requirement where request shall be authenticated using Windows authentication (Active Directory). There shall be 2 roles defined. The roles shall be mapped to the user groups in the Active Directory.
Use PrincipalPermissionAttribute
:
[PrincipalPermission(SecurityAction.Demand, Role = "MySpecialGroup")]
void SomeMethod()
{
// Some Code
}
The role name is the AD group name.
If you need more control you can use PrincipalPermission
:
void SomeMethod()
{
if(!this.IsOwnedByCurrentUser())
{
PrincipalPermission pp = new PrincipalPermission(null, "SomeSpecialGroup");
pp.Demand();
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.