Iterate through the group names to see if the current user is a member of each one : WindowsIdentity : Security C# Examples


C# Examples » Security » WindowsIdentity »

 

Iterate through the group names to see if the current user is a member of each one









    
using  System;
using  System.Security.Principal;

class  MainClass
{
        public  static  void  Main  (string[]  args)  
        {
                
                WindowsIdentity  identity  =  WindowsIdentity.GetCurrent();
                WindowsPrincipal  principal  =  new  WindowsPrincipal(identity);
                
                foreach  (string  role  in  args)  
                {
                        Console.WriteLine("Is  {0}  a  member  of  {1}?  =  {2}",  identity.Name,  role,  principal.IsInRole(role));
                }

        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Security
» WindowsIdentity