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

System.Security.Principal.WindowsIdentity

Represents a Windows user.
namespace System.Security.Principal { public class WindowsIdentity : ClaimsIdentity, IDisposable, IDeserializationCallback, ISerializable { public new const string DefaultIssuer = "AD AUTHORITY"; public SafeAccessTokenHandle AccessToken { get; } public virtual IEnumerable<Claim> DeviceClaims { get; } public IdentityReferenceCollection Groups { get; } public TokenImpersonationLevel ImpersonationLevel { get; } public virtual bool IsAnonymous { get; } public virtual bool IsGuest { get; } public virtual bool IsSystem { get; } public SecurityIdentifier Owner { get; } public virtual IntPtr Token { get; } public SecurityIdentifier User { get; } public virtual IEnumerable<Claim> UserClaims { get; } public WindowsIdentity(IntPtr userToken); public WindowsIdentity(IntPtr userToken, string type); public WindowsIdentity(IntPtr userToken, string type, WindowsAccountType acctType); public WindowsIdentity(IntPtr userToken, string type, WindowsAccountType acctType, bool isAuthenticated); public WindowsIdentity(SerializationInfo info, StreamingContext context); protected WindowsIdentity(WindowsIdentity identity); public WindowsIdentity(string sUserPrincipalName); public void Dispose(); protected virtual void Dispose(bool disposing); public static WindowsIdentity GetAnonymous(); public static WindowsIdentity GetCurrent(); public static WindowsIdentity GetCurrent(bool ifImpersonating); public static WindowsIdentity GetCurrent(TokenAccessLevels desiredAccess); public static void RunImpersonated(SafeAccessTokenHandle safeAccessTokenHandle, Action action); public static Task RunImpersonatedAsync(SafeAccessTokenHandle safeAccessTokenHandle, Func<Task> func); public static Task<T> RunImpersonatedAsync<[System.Runtime.CompilerServices.Nullable(2)] T>(SafeAccessTokenHandle safeAccessTokenHandle, Func<Task<T>> func); public static T RunImpersonated<[System.Runtime.CompilerServices.Nullable(2)] T>(SafeAccessTokenHandle safeAccessTokenHandle, Func<T> func); } }