语言

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 对于未授予的权限,将忽略 ,因为对该权限的需求无法成功。

适用于