How do I use Windows groups for role authorization in WCF?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted May 9, 2011, 11:47 PM EDT
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".