Get the current identity and its associated principal : WindowsIdentity « Security « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » Security » WindowsIdentity 
35.1.3.Get the current identity and its associated principal
using System;
using System.Security.Principal;


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

    
    WindowsPrincipal prin = new WindowsPrincipal(wi);

    Console.WriteLine("Principal information:");
    Console.WriteLine("  Authentication Type: {0}", prin.Identity.AuthenticationType);
    Console.WriteLine("  Is authenticated: {0}", prin.Identity.IsAuthenticated);
    Console.WriteLine("  Name: {0}", prin.Identity.Name);

  }
}
Principal information:
  Authentication Type: NTLM
  Is authenticated: True
  Name: JAVA2S\Joe
35.1.WindowsIdentity
35.1.1.Obtain a WindowsIdentity object representing the currently logged on Windows user
35.1.2.Get the current identity
35.1.3.Get the current identity and its associated principal
35.1.4.Determining group identity: WindowsBuiltInRole.PowerUser
35.1.5.Iterate through the group names to see if the current user is a member of each one
35.1.6.Impersonation
35.1.7.Get current principal identity name
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.