SecurityContext SecurityContext SecurityContext SecurityContext Class

定義

封裝並散佈跨執行緒傳送之執行內容的所有安全性相關資料。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
繼承
SecurityContextSecurityContextSecurityContextSecurityContext
實作

備註

ASecurityContext物件會擷取所有安全性相關的資訊,對於邏輯執行緒,包括在中所包含的資訊WindowsIdentityCompressedStack物件。A SecurityContext object captures all security-related information for a logical thread, including the information contained in the WindowsIdentity and CompressedStack objects. 此組態允許自動傳播時,堆疊上的 Windows 身分識別和安全性項目SecurityContext會複製,並在非同步執行緒之間傳輸。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.

注意

Common language runtime (CLR) 並知道使用 managed 程式碼,不是模擬外部 managed 程式碼,例如執行透過平台執行的作業叫用 unmanaged 程式碼,或透過直接呼叫 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. 如需詳細資訊流動 unmanaged 模擬跨非同步點,請參閱 < <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. 若要直接處置型別,呼叫其Dispose方法中的try / 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() Capture() Capture() Capture()

擷取目前執行緒的安全性內容。Captures the security context for the current thread.

CreateCopy() CreateCopy() CreateCopy() CreateCopy()

建立目前安全性內容的複本。Creates a copy of the current security context.

Dispose() Dispose() Dispose() Dispose()

釋放 SecurityContext 類別目前的執行個體所使用的全部資源。Releases all resources used by the current instance of the SecurityContext class.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
IsFlowSuppressed() IsFlowSuppressed() IsFlowSuppressed() IsFlowSuppressed()

決定安全性內容的流量是否已經抑制。Determines whether the flow of the security context has been suppressed.

IsWindowsIdentityFlowSuppressed() IsWindowsIdentityFlowSuppressed() IsWindowsIdentityFlowSuppressed() IsWindowsIdentityFlowSuppressed()

決定目前安全性內容中 Windows 識別部分的流量是否已抑制。Determines whether the flow of the Windows identity portion of the current security context has been suppressed.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
RestoreFlow() RestoreFlow() RestoreFlow() RestoreFlow()

還原安全性內容在非同步執行緒之間的流量。Restores the flow of the security context across asynchronous threads.

Run(SecurityContext, ContextCallback, Object) Run(SecurityContext, ContextCallback, Object) Run(SecurityContext, ContextCallback, Object) Run(SecurityContext, ContextCallback, Object)

在目前執行緒上的指定安全性內容中執行指定的方法。Runs the specified method in the specified security context on the current thread.

SuppressFlow() SuppressFlow() SuppressFlow() SuppressFlow()

抑制安全性內容在非同步執行緒之間的流量。Suppresses the flow of the security context across asynchronous threads.

SuppressFlowWindowsIdentity() SuppressFlowWindowsIdentity() SuppressFlowWindowsIdentity() SuppressFlowWindowsIdentity()

抑制目前安全性內容中 Windows 識別部分在非同步執行緒之間的流量。Suppresses the flow of the Windows identity portion of the current security context across asynchronous threads.

ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

適用於