RE: SecurityAction RequestOptional, RequestRefuse, & more
- From: v-phuang@xxxxxxxxxxxxxxxxxxxx ("Peter Huang" [MSFT])
- Date: Fri, 10 Jun 2005 06:20:51 GMT
Hi
Here is some information about the SecurityAction.
the RequestMinimum the give your dll the permission.
RequestMinimum
You can use SecurityAction.RequestMinimum method along with declarative
permission attributes to specify the minimum set of permissions your
assembly needs to run. For example, if your assembly needs to access the
registry, but only needs to retrieve configuration data from a specific
key, use an attribute similar to the following:
[assembly: RegistryPermissionAttribute(
SecurityAction.RequestMinimum,
Read=@"HKEY_LOCAL_MACHINE\SOFTWARE\YourApp")]
If you know up front that your code will run in a full trust environment
and will be granted the full set of unrestricted permissions, using
RequestMinimum is less important. However, it is good practice to specify
your assembly's permission requirements.
Note Permission attributes accept a comma-delimited list of properties
and property values after the mandatory constructor arguments. These are
used to initialize the underlying permission object. A quick way to find
out what property names are supported is to use Ildasm.exe on the assembly
that contains the permission attribute type.
RequestOptional
If you use SecurityAction.RequestOptional method, no other permissions
except those specified with SecurityAction.RequestMinimum and
SecurityAction.RequestOptional will be granted to your assembly, even if
your assembly would otherwise have been granted additional permissions by
code access security policy.
RequestRefused
SecurityAction.RequestRefuse allows you to make sure that your assembly
cannot be granted permissions by code access security policy that it does
not require. For example, if your assembly does not call unmanaged code,
you could use the following attribute to ensure code access security policy
does not grant your assembly the unmanaged code permission.
[assembly: SecurityPermissionAttribute(SecurityAction.RequestRefuse,
UnmanagedCode=true)]
......
If you use RequestOptional, the set of permissions that are specified with
RequestOptional and RequestMinimum are INTERSECTED with the permission
grant given to your assembly by policy.
For detailed information, you may try to take a look at the link below.
Code Access Security in Practice
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secmod/html
/secmod81.asp
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
.
- Follow-Ups:
- Re: SecurityAction RequestOptional, RequestRefuse, & more
- From: Nicole Calinoiu
- Re: SecurityAction RequestOptional, RequestRefuse, & more
- References:
- SecurityAction RequestOptional, RequestRefuse, & more
- From: David Thielen
- SecurityAction RequestOptional, RequestRefuse, & more
- Prev by Date: RE: assembly security/permission question
- Next by Date: Re: How to get Drive Volume Name
- Previous by thread: SecurityAction RequestOptional, RequestRefuse, & more
- Next by thread: Re: SecurityAction RequestOptional, RequestRefuse, & more
- Index(es):
Relevant Pages
|