EventLogPermission 類別

定義

控制事件記錄的程式碼存取使用權限。Controls code access permissions for event logging.

public ref class EventLogPermission sealed : System::Security::Permissions::ResourcePermissionBase
[System.Serializable]
public sealed class EventLogPermission : System.Security.Permissions.ResourcePermissionBase
type EventLogPermission = class
    inherit ResourcePermissionBase
Public NotInheritable Class EventLogPermission
Inherits ResourcePermissionBase
繼承
屬性

備註

請勿授EventLogPermission與部分信任的程式碼。Do not grant EventLogPermission to partially trusted code. 讀取和寫入事件記錄檔的功能, 可讓程式碼執行一些動作, 例如以另一個應用程式的名稱發出事件記錄檔訊息。The ability to read and write the event log enables code to perform actions such as issuing event log messages in the name of another application.

注意

如果事件記錄檔的EventLog.Source屬性所指定的事件來源不存在, 就會建立新的事件來源。If the event source that is specified by the EventLog.Source property for the event log does not exist, a new event source is created. 若要在 Windows Vista 和更新版本的 Windows 或 Windows Server 2003 中建立事件來源, 您必須具有系統管理許可權。To create an event source in Windows Vista and later versions of Windows, or Windows Server 2003, you must have administrative privileges.

這項需求的原因是必須搜尋所有事件記錄檔 (包括安全性), 以判斷事件來源是否為唯一的。The reason for this requirement is that all event logs, including security, must be searched to determine whether the event source is unique. 從 Windows Vista 開始, 使用者沒有存取安全性記錄檔的許可權;因此, SecurityException會擲回。Starting with Windows Vista, users do not have permission to access the security log; therefore, a SecurityException is thrown.

從 Windows Vista 開始, 使用者帳戶控制 (UAC) 會判斷使用者的許可權。Starting with Windows Vista, User Account Control (UAC) determines the privileges of a user. 如果您是內建 Administrators 群組的成員,系統會將兩個執行階段存取語彙基元 (Token) 指派給您:標準使用者存取語彙基元及管理員存取語彙基元。If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. 根據預設,您會屬於標準使用者角色。By default, you are in the standard user role. 若要執行可存取安全性記錄檔的程式碼, 您必須先將許可權從標準使用者提升為系統管理員。To execute the code that accesses the security log, you must first elevate your privileges from standard user to administrator. 您可以在啟動應用程式時,以滑鼠右鍵按一下應用程式圖示,並指出您想要以系統管理員身分執行,藉此提高為系統管理員權限。You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator.

建構函式

EventLogPermission()

初始化 EventLogPermission 類別的新執行個體。Initializes a new instance of the EventLogPermission class.

EventLogPermission(EventLogPermissionAccess, String)

使用指定的存取層級和要使用的電腦名稱,初始化 EventLogPermission 類別的新執行個體。Initializes a new instance of the EventLogPermission class with the specified access levels and the name of the computer to use.

EventLogPermission(EventLogPermissionEntry[])

使用指定的使用權限項目,初始化 EventLogPermission 類別的新執行個體。Initializes a new instance of the EventLogPermission class with the specified permission entries.

EventLogPermission(PermissionState)

使用指定的使用權限狀態,初始化 EventLogPermission 類別的新執行個體。Initializes a new instance of the EventLogPermission class with the specified permission state.

欄位

Any

指定用來表示任何萬用字元 (Wildcard Character) 的字元。Specifies the character to be used to represent the any wildcard character.

(繼承來源 ResourcePermissionBase)
Local

指定用來表示區域參考的字元。Specifies the character to be used to represent a local reference.

(繼承來源 ResourcePermissionBase)

屬性

PermissionAccessType

取得或設定一個列舉值,以描述對資源您所授與的存取權類型。Gets or sets an enumeration value that describes the types of access that you are giving the resource.

(繼承來源 ResourcePermissionBase)
PermissionEntries

取得這個使用權限要求的使用權限項目的集合。Gets the collection of permission entries for this permissions request.

TagNames

取得或設定一個字串陣列,以辨識您要保護的資源。Gets or sets an array of strings that identify the resource you are protecting.

(繼承來源 ResourcePermissionBase)

方法

AddPermissionAccess(ResourcePermissionBaseEntry)

將使用權限項目加入至使用權限。Adds a permission entry to the permission.

(繼承來源 ResourcePermissionBase)
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.

(繼承來源 CodeAccessPermission)
Clear()

清除已加入的使用權限項目中的使用權限。Clears the permission of the added permission entries.

(繼承來源 ResourcePermissionBase)
Copy()

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

(繼承來源 ResourcePermissionBase)
Demand()

如果在呼叫堆疊中較高的所有呼叫端都尚未被授與由目前執行個體所指定之權限,則會在執行階段強制執行 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.

(繼承來源 CodeAccessPermission)
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.

(繼承來源 CodeAccessPermission)
Equals(Object)

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

(繼承來源 CodeAccessPermission)
FromXml(SecurityElement)

透過 XML 編碼,重新建構具有指定狀態的安全性物件。Reconstructs a security object with a specified state from an XML encoding.

(繼承來源 ResourcePermissionBase)
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.

(繼承來源 CodeAccessPermission)
GetPermissionEntries()

傳回已加入至這個使用權限的 ResourcePermissionBaseEntry 物件陣列。Returns an array of the ResourcePermissionBaseEntry objects added to this permission.

(繼承來源 ResourcePermissionBase)
GetType()

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

(繼承來源 Object)
Intersect(IPermission)

建立並傳回目前使用權限物件和目標使用權限物件交集的使用權限物件。Creates and returns a permission object that is the intersection of the current permission object and a target permission object.

(繼承來源 ResourcePermissionBase)
IsSubsetOf(IPermission)

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

(繼承來源 ResourcePermissionBase)
IsUnrestricted()

取得值,表示使用權限是否不受限制。Gets a value indicating whether the permission is unrestricted.

(繼承來源 ResourcePermissionBase)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
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.

(繼承來源 CodeAccessPermission)
RemovePermissionAccess(ResourcePermissionBaseEntry)

從使用權限中移除使用權限項目。Removes a permission entry from the permission.

(繼承來源 ResourcePermissionBase)
ToString()

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

(繼承來源 CodeAccessPermission)
ToXml()

建立並傳回安全性物件的 XML 編碼方式和目前狀態。Creates and returns an XML encoding of the security object and its current state.

(繼承來源 ResourcePermissionBase)
Union(IPermission)

建立將目前使用權限物件和目標使用權限物件相結合的使用權限物件。Creates a permission object that combines the current permission object and the target permission object.

(繼承來源 ResourcePermissionBase)

明確介面實作

IPermission.Demand() (繼承來源 CodeAccessPermission)
IStackWalk.Assert() (繼承來源 CodeAccessPermission)
IStackWalk.Demand() (繼承來源 CodeAccessPermission)
IStackWalk.Deny() (繼承來源 CodeAccessPermission)
IStackWalk.PermitOnly() (繼承來源 CodeAccessPermission)

適用於

另請參閱