WindowsPrincipal.Identity Property

 

Gets the identity of the current principal.

Namespace:   System.Security.Principal
Assembly:  mscorlib (in mscorlib.dll)

public override IIdentity Identity { get; }

Property Value

Type: System.Security.Principal.IIdentity

The WindowsIdentity object of the current principal.

The following example retrieves the name of the user by using the Identity property of the WindowsPrincipal object.

WindowsPrincipal wp = new WindowsPrincipal(WindowsIdentity.GetCurrent());
String username = wp.Identity.Name;

.NET Framework
Available since 1.1
Return to top
Show: