How do I use Windows groups for role authorization in WCF?
How do I use Windows groups for role authorization in WCF?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jaganathan BantheswaranPosted May 10, 2011, 3:47 AM
The below code is for determine whether the current principal/user belongs to the Windows user group with the specified name.
WindowsPrincipal myPrincipal = new WindowsPrincipal(ServiceSecurityContext.Current.WindowsIdentity);
if(myPrincipal.IsInRole(@"Windows user group"))
{
//authorized
}
else
{
//not authorized
}
For machine-specific roles, the role string should be in the form "MachineName\RoleNameHere".
For domain-specific roles, the role string should be in the form "DomainName\RoleNameHere"
for example, "SomeDomain\Domain Users".