SecurityContext 類別

定義

警告

Code Access Security is not supported or honored by the runtime.

封裝並散佈跨執行緒傳送之執行內容的所有安全性相關資料。 此類別無法獲得繼承。

public ref class SecurityContext sealed : IDisposable
public ref class SecurityContext sealed
public sealed class SecurityContext : IDisposable
[System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public sealed class SecurityContext : IDisposable
public sealed class SecurityContext
type SecurityContext = class
    interface IDisposable
[<System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type SecurityContext = class
    interface IDisposable
type SecurityContext = class
Public NotInheritable Class SecurityContext
Implements IDisposable
Public NotInheritable Class SecurityContext
繼承
SecurityContext
屬性
實作

備註

注意

此類型在 .NET 6 中標示為過時。

SecurityContext物件會擷取邏輯執行緒的所有安全性相關資訊,包括 和 CompressedStack 物件中包含的 WindowsIdentity 資訊。 此組態可讓堆疊上的Windows身分識別和安全性元素在複製並跨非同步執行緒傳輸時 SecurityContext 自動傳播。

注意

Common Language Runtime (CLR) 知道只使用 Managed 程式碼執行的模擬作業,而不是透過平臺叫用至 Unmanaged 程式碼或直接呼叫 Win32 函式以外的模擬作業。 除非元素已設定為 true () <alwaysFlowImpersonationPolicy enabled="true"/> ,否則 alwaysFlowImpersonationPolicy 只有 Managed WindowsIdentity 物件可以跨非同步點流動。 alwaysFlowImpersonationPolicy將 專案設定為 指定 true 不論模擬的執行方式為何,Windows身分識別一律會跨非同步點流動。 如需跨非同步點流動 Unmanaged 模擬的詳細資訊,請參閱 < alwaysFlowImpersonationPolicy > 元素

SecurityContext是較大 ExecutionContext 和流程的一部分,或是在流程或移轉時 ExecutionContext 進行移轉。

重要

此型別代表 IDisposable 介面。 當您完成使用型別時,您應該直接或間接處置它。 若要直接處置型別,請呼叫其 try/catch 區塊中的 Dispose 方法。 若要間接處置它,請使用語言建構函式,例如 using (在 C# 中) 或 Using (在 Visual Basic 中)。 如需詳細資訊,請參閱 IDisposable 介面文章中的<使用實作 IDisposable 的物件>一節。

方法

Capture()

擷取目前執行緒的安全性內容。

CreateCopy()

建立目前安全性內容的複本。

Dispose()

釋放 SecurityContext 類別目前的執行個體所使用的全部資源。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
IsFlowSuppressed()

決定安全性內容的流量是否已經抑制。

IsWindowsIdentityFlowSuppressed()

決定目前安全性內容中 Windows 識別部分的流量是否已抑制。

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
RestoreFlow()

還原安全性內容在非同步執行緒之間的流量。

Run(SecurityContext, ContextCallback, Object)

在目前執行緒上的指定安全性內容中執行指定的方法。

SuppressFlow()

抑制安全性內容在非同步執行緒之間的流量。

SuppressFlowWindowsIdentity()

抑制目前安全性內容中 Windows 識別部分在非同步執行緒之間的流量。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於