SecurityManager.SecurityEnabled 属性

定义

注意

现已弃用此 API。

注意

Because security can no longer be turned off permanently, setting the SecurityEnabled property no longer has any effect. Reading the property will still indicate whether security has been turned off temporarily.

注意

Because security can no longer be turned off, the SecurityEnabled property no longer has any effect.

获取或设置一个值,该值指示是否启用安全性。

public:
 static property bool SecurityEnabled { bool get(); void set(bool value); };
[System.Obsolete]
public static bool SecurityEnabled { get; set; }
public static bool SecurityEnabled { get; set; }
[System.Obsolete("Because security can no longer be turned off permanently, setting the SecurityEnabled property no longer has any effect. Reading the property will still indicate whether security has been turned off temporarily.")]
public static bool SecurityEnabled { get; set; }
[System.Obsolete("Because security can no longer be turned off, the SecurityEnabled property no longer has any effect.")]
public static bool SecurityEnabled { get; set; }
[<System.Obsolete>]
static member SecurityEnabled : bool with get, set
static member SecurityEnabled : bool with get, set
[<System.Obsolete("Because security can no longer be turned off permanently, setting the SecurityEnabled property no longer has any effect. Reading the property will still indicate whether security has been turned off temporarily.")>]
static member SecurityEnabled : bool with get, set
[<System.Obsolete("Because security can no longer be turned off, the SecurityEnabled property no longer has any effect.")>]
static member SecurityEnabled : bool with get, set
Public Shared Property SecurityEnabled As Boolean

属性值

true 如果启用了安全性,则为否则,为 false.

属性

例外

调用此方法的代码没有 ControlPolicy

注解

此属性由 Caspol.exe 使用(代码访问安全策略工具)

-security-s) 用于关闭基于代码的安全性的选项。

SecurityEnabled 为管理员提供禁用代码访问安全性的方法。 禁用代码访问安全性后,所有代码访问要求都会成功。 实际上,这会授予所有代码 FullTrust。 禁用代码访问安全性会绕过安全系统,以便代码的性能可能略高于授予 FullTrust 所有代码的等效安全策略。 此属性不会禁用基于角色的安全性;因此, PrincipalPermission 需求不会受到影响。

Caution

禁用代码访问安全性会使系统容易受到恶意代码(如病毒和蠕虫)的攻击。 禁用代码访问安全性不会以任何方式阻止托管代码运行。 它只会导致托管代码在不受代码访问安全系统限制的情况下运行,并且只应以最谨慎的方式完成。 只有在采取其他安全措施来帮助保护系统安全性时,才应关闭安全性以获得额外性能。 其他的安全防范措施包括与公共网络断开连接、从物理上保证计算机的安全等等。

在调用之前 SavePolicy ,不会在注册表中保留对此属性的更改。 在更改保留在注册表中之前,新进程不会受到影响。 在正在运行的进程中更改此属性的值不一定按预期方式更改状态。 若要确保更改生效,必须调用 SavePolicy 并启动一个新过程。

适用于