Get the current identity : WindowsIdentity : Security C# Examples


C# Examples » Security » WindowsIdentity »

 

Get the current identity









    
using  System;
using  System.Security.Principal;


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

        Console.WriteLine("Identity  information:");
        Console.WriteLine("    Authentication  Type:  {0}",wi.AuthenticationType);
        Console.WriteLine("    Is  Anonymous:  {0}",  wi.IsAnonymous);
        Console.WriteLine("    Is  Authenticated:  {0}",  wi.IsAuthenticated);
        Console.WriteLine("    Is  Guest:  {0}",  wi.IsGuest);
        Console.WriteLine("    Is  System:  {0}",  wi.IsSystem);
        Console.WriteLine("    Name:  {0}",  wi.Name);
        Console.WriteLine("    Token:  {0}",  wi.Token);
    }
}
    
   
  
   



Output

Identity information:
  Authentication Type: NTLM
  Is Anonymous: False
  Is Authenticated: True
  Is Guest: False
  Is System: False
  Name: navioo\Joe
  Token: 1800


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Security
» WindowsIdentity