CPCericola
July 23rd, 2002, 01:03 PM
I can't understand why these keeps occuring. The following section of code should output two lines saying true:
WindowsIdentity MyIdentity = WindowsIdentity.GetCurrent();
WindowsPrincipal MyPrincipal = new WindowsPrincipal(MyIdentity);
Console.WriteLine(MyPrincipal.IsInRole(WindowsBuiltInRole.Administrator));
Console.WriteLine(MyPrincipal.IsInRole("Administrator"));
Instead, the second IsInRole returns false. I've tried domain\username also and I get the same behaviour. I've also created a testgroup and hadded myself to it. Yet again, it fails. Perhaps I'm missing something?
WindowsIdentity MyIdentity = WindowsIdentity.GetCurrent();
WindowsPrincipal MyPrincipal = new WindowsPrincipal(MyIdentity);
Console.WriteLine(MyPrincipal.IsInRole(WindowsBuiltInRole.Administrator));
Console.WriteLine(MyPrincipal.IsInRole("Administrator"));
Instead, the second IsInRole returns false. I've tried domain\username also and I get the same behaviour. I've also created a testgroup and hadded myself to it. Yet again, it fails. Perhaps I'm missing something?