CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2002
    Location
    Philadelphia, PA
    Posts
    85

    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?

  2. #2
    Join Date
    May 2002
    Location
    Atlanta,GA
    Posts
    262

    Re: WindowsPrincipal.IsInRole question

    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.
    Jared

  3. #3
    Join Date
    Jun 2002
    Location
    Philadelphia, PA
    Posts
    85

    Re: Re: WindowsPrincipal.IsInRole question

    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured