I have two ways to construct the same WindowsPrincipal object
Depending on how I construct it, I get different results for principal.IsInRole()
Here's my code:
var principal1 = new WindowsPrincipal(WindowsIdentity.GetCurrent());
var principal2 = new WindowsPrincipal(new WindowsIdentity("myName"));
principal1.IsInRole("groupName") : returns false
principal2.IsInRole("groupName") : returns true
principal1.Identity.Name
and principal2.Identity.Name
are the same.
Any idea what is happening?