System.Security.SecurityContext.SuppressFlow Method

Suppresses the flow of the security context across asynchronous threads.

Syntax

public static System.Threading.AsyncFlowControl SuppressFlow ()

Returns

An System.Threading.AsyncFlowControl structure for restoring the flow.

Remarks

Use this method to suppress the flow of System.Security.SecurityContext information on the current thread for asynchronous operations.

The common language runtime (CLR) is only aware of the impersonation operations performed using managed code. The CLR has no knowledge of impersonation performed outside of managed code, such as platform invokes to unmanaged code that does the impersonation, or through calls to Win32 functions. To flow identity across asynchronous points you must use the managed System.Security.Principal.WindowsIdentity and System.Security.Principal.WindowsImpersonationContext methods.

Use the System.Threading.AsyncFlowControl.Undo method on the returned System.Threading.AsyncFlowControl structure to return the System.Security.SecurityContext object to its previous state.

This method is protected with a System.Security.Permissions.SecurityAction.LinkDemand for System.Security.Permissions.SecurityPermissionFlag.Infrastructure permission. A fully trusted component can call this method to suppress the flow of the System.Security.SecurityContext information during asynchronous calls. When the flow is suppressed, the SecurityContext.Capture method returns null.

Requirements

Namespace: System.Security
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0