System.Security.Permissions.SecurityPermissionAttribute Class

public sealed class SecurityPermissionAttribute : CodeAccessSecurityAttribute

Base Types

Object
  Attribute
    SecurityAttribute
      CodeAccessSecurityAttribute
        SecurityPermissionAttribute

Assembly

mscorlib

Library

BCL

Summary

Used to apply a security action and a set of security permissions to program code.

Description

[Note: The security permissions are defined in the SecurityPermissionFlag enumeration and are specified using the System.Security.Permissions.SecurityPermissionAttribute.Flags property.

The security information declared by a security attribute is stored in the metadata of the attribute target, and is accessed by the system at run-time. Security attributes are used for declarative security only. For imperative security, use the corresponding permission class, SecurityPermission.

The allowable SecurityPermissionAttribute targets are determined by the SecurityAction passed to the constructor.

]

Example

In the following example, the attribute target is an assembly. The attribute declares that the ability to assert permissions on behalf of callers is the minimum permission required for the assembly to execute.

[assembly:SecurityPermissionAttribute(SecurityAction.RequestMinimum, Assertion=true)]

Attributes

AttributeUsageAttribute(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method, AllowMultiple=true, Inherited=false)

See Also

System.Security.Permissions Namespace

Members

SecurityPermissionAttribute Constructors

SecurityPermissionAttribute Constructor

SecurityPermissionAttribute Methods

SecurityPermissionAttribute.CreatePermission Method

SecurityPermissionAttribute Properties

SecurityPermissionAttribute.Flags Property


SecurityPermissionAttribute Constructor

public SecurityPermissionAttribute(SecurityAction action);

Summary

Constructs and initializes a new instance of the SecurityPermissionAttribute class with the specified SecurityAction value.

Parameters

action
A SecurityAction value.

Exceptions

Exception TypeCondition
ArgumentExceptionaction is not a valid SecurityAction value.

See Also

System.Security.Permissions.SecurityPermissionAttribute Class, System.Security.Permissions Namespace

SecurityPermissionAttribute.CreatePermission Method

public override IPermission CreatePermission();

Summary

Returns a new SecurityPermission object that contains the security information of the current instance.

Return Value

A new SecurityPermission object with the security information of the current instance.

Description

[Note: Applications typically do not call this method; it is intended for use by the system.

The security information declared by a security attribute is stored in the metadata of the attribute target, and is accessed by the system at run-time. The system uses the object returned by this method to convert the security information of the current instance into the form stored in metadata.

This method overrides System.Security.Permissions.SecurityAttribute.CreatePermission.

]

See Also

System.Security.Permissions.SecurityPermissionAttribute Class, System.Security.Permissions Namespace

SecurityPermissionAttribute.Flags Property

public SecurityPermissionFlag Flags { get; set; }

Summary

Gets or sets values that define the permissions declared by the current instance.

Property Value

One or more SecurityPermissionFlag values. To specify multiple values in a set operation, use the bitwise OR operator.

See Also

System.Security.Permissions.SecurityPermissionAttribute Class, System.Security.Permissions Namespace