<PackageReference Include="System.Security.Principal.Windows" Version="5.0.0-preview.1.20120.5" />

WindowsIdentity

Represents a Windows user.
public const string DefaultIssuer = "AD AUTHORITY"

Identifies the name of the default ClaimsIdentity issuer.

Gets this SafeAccessTokenHandle for this WindowsIdentity instance.

public virtual IEnumerable<Claim> DeviceClaims { get; }

Gets claims that have the WindowsDeviceClaim property key.

Gets the groups the current Windows user belongs to.

Gets the impersonation level for the user.

public virtual bool IsAnonymous { get; }

Gets a value that indicates whether the user account is identified as an anonymous account by the system.

public virtual bool IsGuest { get; }

Gets a value indicating whether the user account is identified as a Guest account by the system.

public virtual bool IsSystem { get; }

Gets a value indicating whether the user account is identified as a System account by the system.

public SecurityIdentifier Owner { get; }

Gets the security identifier (SID) for the token owner.

public virtual IntPtr Token { get; }

Gets the Windows account token for the user.

public SecurityIdentifier User { get; }

Gets the security identifier (SID) for the user.

public virtual IEnumerable<Claim> UserClaims { get; }

Gets claims that have the WindowsUserClaim property key.

public WindowsIdentity(IntPtr userToken)

Initializes a new instance of the WindowsIdentity class for the user represented by the specified Windows account token.

public WindowsIdentity(IntPtr userToken, string type)

Initializes a new instance of the WindowsIdentity class for the user represented by the specified Windows account token and the specified authentication type.

public WindowsIdentity(IntPtr userToken, string type, WindowsAccountType acctType)

Initializes a new instance of the WindowsIdentity class for the user represented by the specified Windows account token, the specified authentication type, and the specified Windows account type.

public WindowsIdentity(IntPtr userToken, string type, WindowsAccountType acctType, bool isAuthenticated)

Initializes a new instance of the WindowsIdentity class for the user represented by the specified Windows account token, the specified authentication type, the specified Windows account type, and the specified authentication status.

Initializes a new instance of the WindowsIdentity class for the user represented by information in a SerializationInfo stream.

protected WindowsIdentity(WindowsIdentity identity)

Initializes a new instance of the WindowsIdentity class by using the specified WindowsIdentity object.

public WindowsIdentity(string sUserPrincipalName)

Initializes a new instance of the WindowsIdentity class for the user represented by the specified User Principal Name (UPN).

public static WindowsIdentity GetAnonymous()

Returns a WindowsIdentity object that you can use as a sentinel value in your code to represent an anonymous user. The property value does not represent the built-in anonymous identity used by the Windows operating system.

public static WindowsIdentity GetCurrent()

Returns a WindowsIdentity object that represents the current Windows user.

public static WindowsIdentity GetCurrent(bool ifImpersonating)

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

public static WindowsIdentity GetCurrent(TokenAccessLevels desiredAccess)

Returns a WindowsIdentity object that represents the current Windows user, using the specified desired token access level.

public static void RunImpersonated(SafeAccessTokenHandle safeAccessTokenHandle, Action action)

Runs the specified action as the impersonated Windows identity. Instead of using an impersonated method call and running your function in WindowsImpersonationContext, you can use RunImpersonated and provide your function directly as a parameter.

public static T RunImpersonated<T>(SafeAccessTokenHandle safeAccessTokenHandle, Func<T> func)

Runs the specified function as the impersonated Windows identity. Instead of using an impersonated method call and running your function in WindowsImpersonationContext, you can use RunImpersonated and provide your function directly as a parameter.

public static Task RunImpersonatedAsync(SafeAccessTokenHandle safeAccessTokenHandle, Func<Task> func)

public static Task<T> RunImpersonatedAsync<T>(SafeAccessTokenHandle safeAccessTokenHandle, Func<Task<T>> func)

public void Dispose()

Releases all resources used by the WindowsIdentity.

protected virtual void Dispose(bool disposing)

Releases the unmanaged resources used by the WindowsIdentity and optionally releases the managed resources.