Posted by: Cirilo Meggiolaro | 11/29/2008

Tip of the day #46 – Security Action for declarative security (Assembly level)

Tip #45 explained the basic concepts about declarative and imperative security, when to use and some examples of security permission classes.

You may have realized that when applying declarative security, the first expected parameter is a SecurityAction enumerator item. The security action property guides the CLR about how to perform the security checks.

Let’s take a look today the security action types provided by the .NET framework and that are available for declarative security at the assembly level:

1. RequestMinimum

The RequestMinimum action defines that the assembly requires at least the permission defined by the permission attribute. If the assembly does not have the permission rights, a PolicyException will be thrown.

2. RequestOptional

In practice the RequestOptional action will refuse all permissions other than the declared ones. When you start coding, add a RequestOptional permission is a good practice so you will be obligated to define permissions for only the specific resources your application needs. Based on the fact that this action refuses all other permissions, if you are coding and want to debug an application, the UIPermisssion is required.

3. RequestRefuse

The RequestRefuse action will remove permissions for your assembly. You must use to restrict access to unneeded resources.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: