<PackageReference Include="System.Security.Permissions" Version="9.0.5" />

SecurityContext

public sealed class SecurityContext : IDisposable
Encapsulates and propagates all security-related data for execution contexts transferred across threads. This class cannot be inherited.
public static SecurityContext Capture()

Captures the security context for the current thread.

public static bool IsFlowSuppressed()

Determines whether the flow of the security context has been suppressed.

public static bool IsWindowsIdentityFlowSuppressed()

Determines whether the flow of the Windows identity portion of the current security context has been suppressed.

public static void RestoreFlow()

Restores the flow of the security context across asynchronous threads.

public static void Run(SecurityContext securityContext, ContextCallback callback, object state)

Runs the specified method in the specified security context on the current thread.

Suppresses the flow of the security context across asynchronous threads.

Suppresses the flow of the Windows identity portion of the current security context across asynchronous threads.

Creates a copy of the current security context.

public void Dispose()

Releases all resources used by the current instance of the SecurityContext class.