System.Security.SecurityManager.SecurityEnabled Property

Gets or sets a value indicating whether security is enabled.

Syntax

[System.Obsolete("The security manager cannot be turned off on MS runtime")]
public static bool SecurityEnabled { get; set; }

Value

True to activate the security manager. False to disable the security manager.

Remarks

This property is used by the Caspol.exe (Code Access Security Policy Tool)

-security (-s) option to turn off code-based security.

SecurityManager.SecurityEnabled provides a way for administrators to disable code access security. When code access security is disabled, all code access demands succeed. Effectively, this grants all code FullTrust. Disabling code access security bypasses the security system so that code might perform slightly better than the equivalent security policy granting FullTrust to all code. This property does not disable role-based security; therefore, System.Security.Permissions.PrincipalPermission demands are not affected.

Note:

Disabling code access security makes the system vulnerable to attacks by malicious code such as viruses and worms. Disabling code access security does not automatically block managed code from running in any way. It only causes managed code to run without restriction by the code access security system, and should only be done with the most extreme caution. Turning off security to gain extra performance should only be done when other security measures have been taken to help protect system security. Examples of other security precautions include disconnecting from public networks, physically securing computers, and so on.

A change to this property is not persisted in the registry until SecurityManager.SavePolicy is called. New processes will not be affected by the change until it is persisted in the registry. Changing the value of this property in a running process does not necessarily change the state in the expected manner. To ensure changes have taken effect, you must call SecurityManager.SavePolicy and start a new process.

Requirements

Namespace: System.Security
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0