This documentation is archived and is not being maintained.

WindowsIdentity.GetCurrent Method (Boolean)

Returns a WindowsIdentity object that represents the Windows identity for either the thread or the process, depending on the value of the ifImpersonating parameter.

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

[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlPrincipal)]
public static WindowsIdentity GetCurrent(
	bool ifImpersonating
)

Parameters

ifImpersonating
Type: System.Boolean
true to return the WindowsIdentity only if the thread is currently impersonating; false to return the WindowsIdentity of the thread if it is impersonating or the WindowsIdentity of the process if the thread is not currently impersonating.

Return Value

Type: System.Security.Principal.WindowsIdentity
An object that represents a Windows user.

If ifImpersonating is true and the thread is not impersonating, the returned WindowsIdentity object has no value. If ifImpersonating is false and the thread is impersonating, the WindowsIdentity for the thread is returned. If ifImpersonating is false and the thread is not impersonating, the WindowsIdentity for the process is returned.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: