PC Review


Reply
Thread Tools Rate Thread

Custom principles and DnsPermission.Demand()

 
 
andrew lowe
Guest
Posts: n/a
 
      24th Mar 2005
Hi

We have windows application and have created our own custom principle &
identity objects that implement IPrinciple and IIdentity. When a user logs
into our system we set the threads principle to our custom principle object
by calling Thread.CurrentPrinciple = blah. This all works great for role
based security. BUT lets say i want to run one line of code which causes an
imperative security demand:

Dns.GetHostName();

CAS will now throw security exceptions when we try to run code that demands
permissions. I thought the following code might be a work around

IPrincipal currentPrinciple = Thread.CurrentPrincipal;
try
{
Thread.CurrentPrincipal = new
WindowsPrincipal(WindowsIdentity.GetCurrent());
Dns.GetHostName();
}
finally
{
Thread.CurrentPrincipal = currentPrinciple;
}

But alas the DnsPermission.Demand() still throws a security exception. I
think the following article and quote might explain why
http://support.microsoft.com/default...b;en-us;318169

"Imperative security uses code that is executed at run time to enforce
security. At run time, when a Demand method is called from an Identity
Permission class, the call stack is evaluated to verify the code. If there
is a point in the call stack where assemblies that were previously called do
not have the same identity as the code, exceptions are thrown."

So, I wish to use alot of classes that have security demands in them but if
i use my own principle objects i can no longer use them. It seems to be a
wee bit of a conundrum. Anyone have any thoughts besides

tia
andrew


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Principles behind 2D drawing Jay Dee Thompson Microsoft C# .NET 5 4th Jan 2009 01:37 AM
Custom toolbar - how to save in file and show on demand? igivanovg@gmail.com Microsoft Excel Programming 3 5th May 2008 07:45 PM
OOP Principles Scott Schluer Microsoft VB .NET 2 30th Sep 2004 05:25 PM
C-sharp demand on par with Assembler - Apache releases a Java app server (Re: Skills in most demand) asj Microsoft VB .NET 189 8th Jul 2004 08:48 PM
Yet another study says: Java is most in demand (Re: C-sharp demand on par with Assembler) asj Microsoft C# .NET 3 16th Jun 2004 07:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:35 AM.