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
實作

備註

物件會捕捉邏輯執行緒的所有安全性相關資訊, 包括WindowsIdentityCompressedStack物件中包含的資訊。 SecurityContextA 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) 會感知僅使用 managed 程式碼執行的模擬作業, 而不是在 managed 程式碼外部執行的模擬, 例如透過平台叫用來進行非受控程式碼, 或透過直接呼叫 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已設定為true (<alwaysFlowImpersonationPolicy enabled="true"/>), 否則只有managed物件可以alwaysFlowImpersonationPolicy流經非同步點。Only managed WindowsIdentity objects can flow across asynchronous points, unless the alwaysFlowImpersonationPolicy element has been set to true (<alwaysFlowImpersonationPolicy enabled="true"/>). 設定元素以true指定 Windows 識別一律流經非同步點, 不論模擬的執行方式為何。 alwaysFlowImpersonationPolicySetting 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.

屬於較大ExecutionContext的和ExecutionContext流程, 或在流程或遷移時遷移。 SecurityContextThe 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. 若要直接處置型別,請呼叫其 try/catch 區塊中的 Dispose 方法。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 的淺層複本 (Shallow Copy)。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()

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

(繼承來源 Object)

適用於