SecurityAction Enum
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Caution
Code Access Security is not supported or honored by the runtime.
Specifies the security actions that can be performed using declarative security.
public enum class SecurityAction
[System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public enum SecurityAction
public enum SecurityAction
[System.Serializable]
public enum SecurityAction
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum SecurityAction
[<System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type SecurityAction =
type SecurityAction =
[<System.Serializable>]
type SecurityAction =
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type SecurityAction =
Public Enum SecurityAction
- Inheritance
- Attributes
Fields
Name | Value | Description |
---|---|---|
Demand | 2 | All callers higher in the call stack are required to have been granted the permission specified by the current permission object. |
Assert | 3 | The calling code can access the resource identified by the current permission object, even if callers higher in the stack have not been granted permission to access the resource (see Using the Assert Method). |
Deny | 4 | The ability to access the resource specified by the current permission object is denied to callers, even if they have been granted permission to access it (see Using the Deny Method). |
PermitOnly | 5 | Only the resources specified by this permission object can be accessed, even if the code has been granted permission to access other resources. |
LinkDemand | 6 | The immediate caller is required to have been granted the specified permission. Do not use in the .NET Framework 4. For full trust, use SecurityCriticalAttribute instead; for partial trust, use Demand. |
InheritanceDemand | 7 | The derived class inheriting the class or overriding a method is required to have been granted the specified permission. |
RequestMinimum | 8 | The request for the minimum permissions required for code to run. This action can only be used within the scope of the assembly. |
RequestOptional | 9 | The request for additional permissions that are optional (not required to run). This request implicitly refuses all other permissions not specifically requested. This action can only be used within the scope of the assembly. |
RequestRefuse | 10 | The request that permissions that might be misused will not be granted to the calling code. This action can only be used within the scope of the assembly. |
Remarks
Caution
Code Access Security (CAS) has been deprecated across all versions of .NET Framework and .NET. Recent versions of .NET do not honor CAS annotations and produce errors if CAS-related APIs are used. Developers should seek alternative means of accomplishing security tasks.
The following table describes the time that each security action takes place and the targets that it supports.
Important
In .NET Framework 4, runtime support has been removed for enforcing the Deny, RequestMinimum, RequestOptional, and RequestRefuse permission requests. These requests should not be used in code that is based on .NET Framework 4 or later. For more information about this and other changes, see Security Changes.
You should not use LinkDemand
in .NET Framework 4. Instead, use the SecurityCriticalAttribute to restrict usage to fully trusted applications, or use Demand
to restrict partially trusted callers.
Declaration of security action | Time of action | Targets supported |
---|---|---|
LinkDemand (do not use in .NET Framework 4+) |
Just-in-time compilation | Class, method |
InheritanceDemand |
Load time | Class, method |
Demand |
Run time | Class, method |
Assert |
Run time | Class, method |
Deny (obsolete in .NET Framework 4) |
Run time | Class, method |
PermitOnly |
Run time | Class, method |
RequestMinimum (obsolete in .NET Framework 4) |
Grant time | Assembly |
RequestOptional (obsolete in .NET Framework 4) |
Grant time | Assembly |
RequestRefuse (obsolete in .NET Framework 4) |
Grant time | Assembly |
For additional information about attribute targets, see Attribute.