WindowsPrincipal::Identity Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets the identity of the current principal.

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

property IIdentity^ Identity {
	virtual IIdentity^ get() override;

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 = gcnew WindowsPrincipal( WindowsIdentity::GetCurrent() );
String^ username = wp->Identity->Name;

.NET Framework
Available since 1.1
Return to top