SecurityManager.SecurityEnabled Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Note: This API is now obsolete.

Gets or sets a value indicating whether security is enabled.

Namespace:   System.Security
Assembly:  mscorlib (in mscorlib.dll)

[ObsoleteAttribute("Because security can no longer be turned off, the SecurityEnabled property no longer has any effect.")]
public static bool SecurityEnabled { get; set; }

Property Value

Type: System.Boolean

true if security is enabled; otherwise, false.

Exception Condition
SecurityException

The code that calls this method does not have SecurityPermissionFlag.ControlPolicy.

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

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

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, PrincipalPermission demands are not affected.

System_CAPS_cautionCaution

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 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 SavePolicy and start a new process.

SecurityPermission

for the ability to modify policy. Associated enumeration: SecurityPermissionFlag.ControlPolicy

.NET Framework
Available since 1.1
Return to top
Show: