Determining group identity : WindowsIdentity : Security C# Examples


C# Examples » Security » WindowsIdentity »

 

Determining group identity









    
using  System;
using  System.Security.Principal;

class  MainClass
{
    public  static  void  Main()  
    {
        WindowsIdentity  wi  =  WindowsIdentity.GetCurrent();
        WindowsPrincipal  prin  =  new  WindowsPrincipal(wi);

        if  (prin.IsInRole(WindowsBuiltInRole.PowerUser))  
        {
            Console.WriteLine("You  are  a  member  of  the  Power  User  group");
        }
        else
        {
            Console.WriteLine("You  are  not  a  member  of  the  Power  User  group");
        }
    }
}
    
   
  
   



Output

You are not a member of the Power User group


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Security
» WindowsIdentity