-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: Varad_RS
Message 52 in Discussion

Security: Declarative Permissions
-----------------------------------------------

In most of our assembly coding we reference assembly-level permissions in 
square or circular brackets for C# and VB.NET, respectively. These are 
called declarative permissions. You can also employ imperative security by 
creating permission objects within your code. For example,

new FileIOPermission(FileIOPermissionAccess.Read, 
@"C:\myfiles\inventory.xml").Demand();

This will raise an exception if the code is not granted the permission to 
read the particular XML file.

We need to make sure the code catches any such exceptions; otherwise, it 
will stop the further execution (In this care it's a show stopper!)

There are advantages and disadvantages to each method. Declarative 
permission is good because it's easy to use and readable in code. 
Declarative permissions can be viewed with the Permissions View tool (known 
as permview) - normally used with the command /decl switch - to perform code 
reviews. Changes in control flow don't avoid the check, and they can be 
applied to entire classes.

The major declarative drawback is the fact that the state of the permission 
must be known only at compile time.


Regards,
Varad
http://weblogs.asp.net/Varad
       "We Learn Together & We Grow Together"

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/



-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to