Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Security / April 2006

Tip: Looking for answers? Try searching our database.

Help me to undersand ???

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
serge calderara - 25 Apr 2006 10:17 GMT
Dear all,

I am practiciing security in .NET, partriculary CAS.
For that I have a simple example that I try to run on my system. This
example is issue from MS-Press books lab and is as follow :

==========================
<Assembly: PrintingPermission(SecurityAction.RequestMinimum)>
<Assembly: FileIOPermission(SecurityAction.RequestOptional, Read:="C:\")>
<Assembly: FileIOPermission(SecurityAction.RequestRefuse,
Read:="C:\Windows\")>

Module Module1

   Sub Main()
       Console.WriteLine("Rad boot.ini file line")
       Dim sr As StreamReader = New StreamReader("c:\boot.ini")
       Console.WriteLine("line red : " & sr.ReadLine)
       Console.ReadLine()
   End Sub

=========================

When executing this code, I get following error :

"An unhandled exception of type 'System.Security.Policy.PolicyException'
occurred in Unknown Module.
Additional information: Required permissions cannot be acquired."

I have reset all my CAS setting to default, to be sure that I did not make
someting wrong.

What can I check to make it work ?

thnaks for help
regard
Serge
Nicole Calinoiu - 25 Apr 2006 15:32 GMT
Are you trying to run it from within VStudio?  If so, you'll need
unrestricted UIPermission as well.

> Dear all,
>
[quoted text clipped - 33 lines]
> regard
> Serge
serge calderara - 26 Apr 2006 08:04 GMT
hi,

Yes I am running it within visual studio.
I have default settings under CAS, it means that I get Unrestricted  already
no ?

could you clarify one point for me that I reaaly do not catch.
First of all when you apply security for a file/folder with with Windows
explorer, you select the folder or file then add users or group permission
for that folder or file.

Then for assemblies, how does it really work. Does the .NET framework by
default run the assemblie inside all level ( Enterprise, Machine, users) with
default access and then you only start to fine tune security in your code as
imperative or declarative way ?

Or are you able to select within CAS tool, your assembly name then similar
as a folder specify the level in which you want to run your assembly and
finally security rules ?

thnaks for your info
regards
serge

> Are you trying to run it from within VStudio?  If so, you'll need
> unrestricted UIPermission as well.
[quoted text clipped - 36 lines]
> > regard
> > Serge
Nicole Calinoiu - 26 Apr 2006 14:44 GMT
> hi,
>
> Yes I am running it within visual studio.
> I have default settings under CAS, it means that I get Unrestricted
> already
> no ?

Your assembly may be granted unrestricted permissions under CAS policy, but
using even one RequestOptional is effectively equivalent to rejecting all
permissions that you do not explicitly request via either a RequestMinimum
or RequestOptional.  In order to gain back UIPermission, you would need to
request it.  e.g.:

<Assembly: UIPermission(SecurityAction.RequestMinimum, Unrestricted:=True)>

> could you clarify one point for me that I reaaly do not catch.
> First of all when you apply security for a file/folder with with Windows
[quoted text clipped - 7 lines]
> as
> imperative or declarative way ?

No.  For starters, when the terms "imperative" and "declarative" are used
for CAS, they almost always refer to demanding permissions, not setting
them.  While the assembly-level permissions you are applying are, strictly
speaking, an application of a declarative syntax, they are not used for
demanding permissions.

In addition, assembly-level permission attributes can only be used to
decrease, not increase, the permission grant for an assembly.  They are not
used so much for "fine tuning" as they are for either documenting required
permissions or deliberately restricting what an assembly is allowed to do.

> Or are you able to select within CAS tool, your assembly name then similar
> as a folder specify the level in which you want to run your assembly and
> finally security rules ?

You can grant permissions at the assembly level via CAS policy if you so
desire.  However, that's just one of many possible adjustments one might
wish to make to the policy.
serge calderara - 27 Apr 2006 06:31 GMT
Thnaks nicole.

I am actually prpearing my MCSD and i select as next exam .Net security. For
that I get the MS -Express book which is quite well explain as long as you
have catch the idea. Sounds a bit clear for me now

have you ever rrun in that book ? do you thonk it would be enought ?
Of cours a lot of more info on MSDN too that I found

regards
serge

> > hi,
> >
[quoted text clipped - 41 lines]
> desire.  However, that's just one of many possible adjustments one might
> wish to make to the policy.
Nicole Calinoiu - 27 Apr 2006 14:34 GMT
I am unfamiliar with the book, so I can't comment on its contents.

> Thnaks nicole.
>
[quoted text clipped - 69 lines]
>> desire.  However, that's just one of many possible adjustments one might
>> wish to make to the policy.
serge calderara - 27 Apr 2006 14:44 GMT
how deep are you involev with security in your daily work ?
Do you work in a company or as a consultant in security ?

> I am unfamiliar with the book, so I can't comment on its contents.
>
[quoted text clipped - 71 lines]
> >> desire.  However, that's just one of many possible adjustments one might
> >> wish to make to the policy.
Nicole Calinoiu - 27 Apr 2006 14:56 GMT
I work at a developer and architect at a software company, not as a security
consultant.  Security is not the main focus of my job, but it is an
important consideration in my work.

> how deep are you involev with security in your daily work ?
> Do you work in a company or as a consultant in security ?
[quoted text clipped - 86 lines]
>> >> might
>> >> wish to make to the policy.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.