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.

注意

The security manager cannot be turned off on MS runtime

获取或设置指示是否启用安全的值。

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("The security manager cannot be turned off on MS runtime")]
public static bool SecurityEnabled { get; set; }
[<System.Obsolete>]
member this.SecurityEnabled : bool with get, set
member this.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.")>]
member this.SecurityEnabled : bool with get, set
[<System.Obsolete("Because security can no longer be turned off, the SecurityEnabled property no longer has any effect.")>]
member this.SecurityEnabled : bool with get, set
[<System.Obsolete("The security manager cannot be turned off on MS runtime")>]
member this.SecurityEnabled : bool with get, set
Public Shared Property SecurityEnabled As Boolean

属性值

Boolean

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

属性

例外

调用此方法的代码不含 ControlPolicy

注解

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

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

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

注意

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

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

适用于