SecurityContext 类

定义

封装并传播在线程间传输的执行上下文的所有安全相关数据。Encapsulates and propagates all security-related data for execution contexts transferred across threads. 无法继承此类。This class cannot be inherited.

public ref class SecurityContext sealed : IDisposable
public sealed class SecurityContext : IDisposable
type SecurityContext = class
    interface IDisposable
Public NotInheritable Class SecurityContext
Implements IDisposable
继承
SecurityContext
实现

注解

SecurityContext 对象捕获逻辑线程的所有安全相关信息,包括 WindowsIdentityCompressedStack 对象中包含的信息。A SecurityContext object captures all security-related information for a logical thread, including the information contained in the WindowsIdentity and CompressedStack objects. 此配置允许在异步线程之间复制和传输 SecurityContext 时,自动传播 Windows 标识和堆栈上的安全元素。This configuration allows the Windows identity and the security elements on the stack to be propagated automatically when the SecurityContext is copied and transferred across asynchronous threads.

备注

公共语言运行时(CLR)知道仅使用托管代码执行的模拟操作,而不是在托管代码之外执行的模拟,例如通过平台调用到非托管代码或通过直接调用 Win32 函数。The common language runtime (CLR) is aware of impersonation operations performed using only managed code, not of impersonation performed outside of managed code, such as through platform invoke to unmanaged code or through direct calls to Win32 functions. 只有托管 WindowsIdentity 对象才能流经异步点,除非已将 alwaysFlowImpersonationPolicy 元素设置为 true<alwaysFlowImpersonationPolicy enabled="true"/>)。Only managed WindowsIdentity objects can flow across asynchronous points, unless the alwaysFlowImpersonationPolicy element has been set to true (<alwaysFlowImpersonationPolicy enabled="true"/>). alwaysFlowImpersonationPolicy 元素设置为 "true 指定无论模拟的执行方式如何,Windows 标识总是流经异步点。Setting the alwaysFlowImpersonationPolicy element to true specifies that the Windows identity always flows across asynchronous points, regardless of how impersonation was performed. 有关跨异步点流动非托管模拟的详细信息,请参阅<alwaysFlowImpersonationPolicy> 元素For more information about flowing unmanaged impersonation across asynchronous points, see <alwaysFlowImpersonationPolicy> Element.

SecurityContext 是较大 ExecutionContext 的一部分,在 ExecutionContext 流或迁移时进行流或迁移。The SecurityContext is part of the larger ExecutionContext and flows or migrates when the ExecutionContext flows or migrates.

重要

此类型实现 IDisposable 接口。This type implements the IDisposable interface. 在使用完类型后,您应直接或间接释放类型。When you have finished using the type, you should dispose of it either directly or indirectly. 若要直接释放类型,请在 Disposetry/ 块中调用其 catch 方法。To dispose of the type directly, call its Dispose method in a try/catch block. 若要间接释放类型,请使用 using(在 C# 中)或 Using(在 Visual Basic 中)等语言构造。To dispose of it indirectly, use a language construct such as using (in C#) or Using (in Visual Basic). 有关详细信息,请参阅 IDisposable 接口主题中的“使用实现 IDisposable 的对象”一节。For more information, see the "Using an Object that Implements IDisposable" section in the IDisposable interface topic.

方法

Capture()

捕获当前线程的安全上下文。Captures the security context for the current thread.

CreateCopy()

创建当前安全上下文的副本。Creates a copy of the current security context.

Dispose()

释放 SecurityContext 类的当前实例所使用的所有资源。Releases all resources used by the current instance of the SecurityContext class.

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
IsFlowSuppressed()

确定是否已取消安全上下文的流动。Determines whether the flow of the security context has been suppressed.

IsWindowsIdentityFlowSuppressed()

确定是否已取消当前安全上下文的 Windows 标识部分的流动。Determines whether the flow of the Windows identity portion of the current security context has been suppressed.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
RestoreFlow()

在异步线程间恢复安全上下文的流动。Restores the flow of the security context across asynchronous threads.

Run(SecurityContext, ContextCallback, Object)

在当前线程上指定的安全上下文中运行指定的方法。Runs the specified method in the specified security context on the current thread.

SuppressFlow()

在异步线程间取消安全上下文的流动。Suppresses the flow of the security context across asynchronous threads.

SuppressFlowWindowsIdentity()

在异步线程间取消当前安全上下文的 Windows 标识部分的流动。Suppresses the flow of the Windows identity portion of the current security context across asynchronous threads.

ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

适用于