PermissionSet.Deny 方法

定義

警告

此 API 現已淘汰。

警告

Deny is obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.

會讓任何通過權限呼叫程式碼的 Demand() 失敗,該權限與目前 PermissionSet 中包含的權限類型有交集。

public:
 virtual void Deny();
[System.Obsolete]
public void Deny ();
public virtual void Deny ();
public void Deny ();
[System.Obsolete("Deny is obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
public void Deny ();
[<System.Obsolete>]
abstract member Deny : unit -> unit
override this.Deny : unit -> unit
abstract member Deny : unit -> unit
override this.Deny : unit -> unit
[<System.Obsolete("Deny is obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")>]
abstract member Deny : unit -> unit
override this.Deny : unit -> unit
Public Sub Deny ()
Public Overridable Sub Deny ()

實作

屬性

例外狀況

先前呼叫 Deny() 已限制目前堆疊框架的權限。

備註

此方法可防止呼叫堆疊中的呼叫端透過呼叫此方法的程式碼存取受保護的資源,即使這些呼叫端已獲授與存取它的許可權也一樣。 呼叫堆疊通常表示為向下成長,因此呼叫堆疊呼叫方法中的方法會降低呼叫堆疊。

Deny 可以限制程式設計人員的責任,或協助防止意外的安全性弱點,因為它有助於防止呼叫 Deny 的方法用來存取受拒絕許可權保護的資源。 如果方法在許可權上呼叫 Deny ,而且呼叫 Demand 堆疊中較低呼叫端會叫用該許可權的 ,該安全性檢查會在到達 Deny 時失敗。

Deny 忽略未授與許可權的許可權,因為該許可權的要求無法成功。

適用於