WindowsPrincipal.IsInRole question
I can't understand why these keeps occuring. The following section of code should output two lines saying true:
Code:
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?
Re: WindowsPrincipal.IsInRole question
Quote:
Originally posted by CPCericola
I can't understand why these keeps occuring. The following section of code should output two lines saying true:
Code:
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?
I've tried the same thing and I"m getting the same error. It's very baffling.
Re: Re: WindowsPrincipal.IsInRole question
Quote:
Originally posted by jparsons
I've tried the same thing and I"m getting the same error. It's very baffling.
I think I figured it out. It's talking about the Domain/Computer role not group. If I'm not mistaken, isn't there a difference between these two?