EnvironmentPermission EnvironmentPermission EnvironmentPermission EnvironmentPermission Class

定義

控制系統和使用者環境變數的存取。Controls access to system and user environment variables. 這個類別無法被繼承。This class cannot be inherited.

public ref class EnvironmentPermission sealed : System::Security::CodeAccessPermission, System::Security::Permissions::IUnrestrictedPermission
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public sealed class EnvironmentPermission : System.Security.CodeAccessPermission, System.Security.Permissions.IUnrestrictedPermission
type EnvironmentPermission = class
    inherit CodeAccessPermission
    interface IUnrestrictedPermission
Public NotInheritable Class EnvironmentPermission
Inherits CodeAccessPermission
Implements IUnrestrictedPermission
繼承
EnvironmentPermissionEnvironmentPermissionEnvironmentPermissionEnvironmentPermission
屬性
實作

備註

環境變數名稱所指定的一或多個使用分號分隔,與不同的清單,針對讀取和寫入存取權的具名變數的不區分大小寫的名稱清單。Environment variable names are designated by one or more case-insensitive name lists separated by semicolons, with separate lists for read and write access to the named variables. 寫入權限包括建立和刪除環境變數,以及變更現有值的能力。Write access includes the ability to create and delete environment variables as well as to change existing values.

注意

在之前的.NET Framework 的版本中.NET Framework 4.NET Framework 4,您可以使用CodeAccessPermission.Deny方法,以防止意外存取系統資源受信任的程式碼。In versions of the .NET Framework before the .NET Framework 4.NET Framework 4, you could use the CodeAccessPermission.Deny method to prevent inadvertent access to system resources by trusted code. Deny 現已淘汰,並存取資源現在僅取決於授與的權限集合組件。Deny is now obsolete, and access to resources is now determined solely by the granted permission set for an assembly. 若要限制檔案的存取權,您必須在沙箱中執行部分信任程式碼,並將指派給它的權限的程式碼可以存取的資源。To limit access to files, you must run partially trusted code in a sandbox and assign it permissions only to resources that the code is allowed to access. 如需在沙箱中執行的應用程式的資訊,請參閱How to:在沙箱中執行部分信任的程式碼中所述。For information about running an application in a sandbox, see How to: Run Partially Trusted Code in a Sandbox.

建構函式

EnvironmentPermission(EnvironmentPermissionAccess, String) EnvironmentPermission(EnvironmentPermissionAccess, String) EnvironmentPermission(EnvironmentPermissionAccess, String) EnvironmentPermission(EnvironmentPermissionAccess, String)

使用指定之環境變數的指定存取權,來初始化 EnvironmentPermission 類別的新執行個體。Initializes a new instance of the EnvironmentPermission class with the specified access to the specified environment variables.

EnvironmentPermission(PermissionState) EnvironmentPermission(PermissionState) EnvironmentPermission(PermissionState) EnvironmentPermission(PermissionState)

使用指定的受限制或不受限制使用權限,來初始化 EnvironmentPermission 類別的新執行個體。Initializes a new instance of the EnvironmentPermission class with either restricted or unrestricted permission as specified.

方法

AddPathList(EnvironmentPermissionAccess, String) AddPathList(EnvironmentPermissionAccess, String) AddPathList(EnvironmentPermissionAccess, String) AddPathList(EnvironmentPermissionAccess, String)

將指定環境變數的存取加入此權限的現有狀態。Adds access for the specified environment variables to the existing state of the permission.

Assert() Assert() Assert() Assert()

宣告即使堆疊中較高層的呼叫端未獲得資源存取權限,呼叫程式碼仍可透過呼叫這個方法的程式碼要求權限,來存取受保護的資源。Declares that the calling code can access the resource protected by a permission demand through the code that calls this method, even if callers higher in the stack have not been granted permission to access the resource. 使用 Assert() 可能會造成安全性問題。Using Assert() can create security issues.

(Inherited from CodeAccessPermission)
Copy() Copy() Copy() Copy()

建立並傳回目前權限的相同複本。Creates and returns an identical copy of the current permission.

Demand() Demand() Demand() Demand()

如果呼叫堆疊中所有較高層的呼叫端尚未授與目前執行個體 (Instance) 所指定的使用權限,請於執行階段強制執行 SecurityExceptionForces a SecurityException at run time if all callers higher in the call stack have not been granted the permission specified by the current instance.

(Inherited from CodeAccessPermission)
Deny() Deny() Deny() Deny()

防止呼叫堆疊中較高層的呼叫端,使用呼叫這個方法的程式碼來存取目前執行個體所指定的資源。Prevents callers higher in the call stack from using the code that calls this method to access the resource specified by the current instance.

(Inherited from CodeAccessPermission)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from CodeAccessPermission)
FromXml(SecurityElement) FromXml(SecurityElement) FromXml(SecurityElement) FromXml(SecurityElement)

使用 XML 編碼方式重建具有指定狀態的使用權限。Reconstructs a permission with a specified state from an XML encoding.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

取得 CodeAccessPermission 物件的雜湊碼,其適合用於雜湊表這類的雜湊演算法和資料結構。Gets a hash code for the CodeAccessPermission object that is suitable for use in hashing algorithms and data structures such as a hash table.

(Inherited from CodeAccessPermission)
GetPathList(EnvironmentPermissionAccess) GetPathList(EnvironmentPermissionAccess) GetPathList(EnvironmentPermissionAccess) GetPathList(EnvironmentPermissionAccess)

使用指定的 EnvironmentPermissionAccess 取得所有的環境變數。Gets all environment variables with the specified EnvironmentPermissionAccess.

GetType() GetType() GetType() GetType()

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

(Inherited from Object)
Intersect(IPermission) Intersect(IPermission) Intersect(IPermission) Intersect(IPermission)

建立並傳回目前使用權限和指定之使用權限交集的使用權限。Creates and returns a permission that is the intersection of the current permission and the specified permission.

IsSubsetOf(IPermission) IsSubsetOf(IPermission) IsSubsetOf(IPermission) IsSubsetOf(IPermission)

判斷目前使用權限是否為指定之使用權限的子集。Determines whether the current permission is a subset of the specified permission.

IsUnrestricted() IsUnrestricted() IsUnrestricted() IsUnrestricted()

傳回數值,表示目前使用權限是否不受限制。Returns a value indicating whether the current permission is unrestricted.

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

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

(Inherited from Object)
PermitOnly() PermitOnly() PermitOnly() PermitOnly()

防止呼叫堆疊中較高層的呼叫端,使用呼叫這個方法的程式碼來存取除了目前執行個體所指定資源之外的所有資源。Prevents callers higher in the call stack from using the code that calls this method to access all resources except for the resource specified by the current instance.

(Inherited from CodeAccessPermission)
SetPathList(EnvironmentPermissionAccess, String) SetPathList(EnvironmentPermissionAccess, String) SetPathList(EnvironmentPermissionAccess, String) SetPathList(EnvironmentPermissionAccess, String)

將指定之環境變數的指定存取設定為現有的使用權限狀態。Sets the specified access to the specified environment variables to the existing state of the permission.

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

建立並傳回目前使用權限物件的字串表示。Creates and returns a string representation of the current permission object.

(Inherited from CodeAccessPermission)
ToXml() ToXml() ToXml() ToXml()

建立使用權限的 XML 編碼方式,和其目前狀態。Creates an XML encoding of the permission and its current state.

Union(IPermission) Union(IPermission) Union(IPermission) Union(IPermission)

建立目前權限與指定權限聯集的權限。Creates a permission that is the union of the current permission and the specified permission.

明確介面實作

IPermission.Demand() IPermission.Demand() IPermission.Demand() IPermission.Demand() Inherited from CodeAccessPermission
IStackWalk.Assert() IStackWalk.Assert() IStackWalk.Assert() IStackWalk.Assert() Inherited from CodeAccessPermission
IStackWalk.Demand() IStackWalk.Demand() IStackWalk.Demand() IStackWalk.Demand() Inherited from CodeAccessPermission
IStackWalk.Deny() IStackWalk.Deny() IStackWalk.Deny() IStackWalk.Deny() Inherited from CodeAccessPermission
IStackWalk.PermitOnly() IStackWalk.PermitOnly() IStackWalk.PermitOnly() IStackWalk.PermitOnly() Inherited from CodeAccessPermission

適用於

另請參閱