HighTechTalks DotNet Forums  

Yet another Network App question (slightly different though);

Dotnet Security microsoft.public.dotnet.security


Discuss Yet another Network App question (slightly different though); in the Dotnet Security forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Matt Budd
 
Posts: n/a

Default Yet another Network App question (slightly different though); - 06-22-2004 , 01:49 PM






Hello all,

I've looked through this newsgroup and saw lots of questions about running
an application from a network drive or a local network. I know that when you
do this, it puts the assembly into a different "zone" of trust which is more
restrictive.

In my situation this is a good thing. We don't want to allow our application
to be run over the network and want to force them to install it (and buy it)
on each local machine. The problem I'm having is that when you attempt to
run it off the network drive, it dies on you and you get a
System.Security.SecurityException unhandled exception. What I want to do is
basically catch this exception and then display a readable error message
explaining that it has to be run locally.

I've tried the following code at the very start of my Main() function:
[STAThread]
static void Main(string[] pasArgs)
{
try {
if
(System.Security.SecurityManager.ResolvePolicy(typ eof(frmMain).Assembly.Evid
ence).IsUnrestricted() == false) {
MessageBox.Show("Must run locally!");
return;
}
} catch (System.Security.SecurityException e) {
MessageBox.Show(e.ToString());
return;
}


But I still get the exception and neither of my messageboxes show. Any ideas
how to catch this exception?

- Matt



Reply With Quote
  #2  
Old   
Fernando Vicaria [MSFT]
 
Posts: n/a

Default Re: Yet another Network App question (slightly different though); - 06-23-2004 , 06:23 PM






Hi Matt,

You would need to demand for an identity permission here, either Zone or
Url. But this on its own is easy to fake so you should think of additional
security checks such as strong name or/and the use of an intermediate caller
assembly which will have your security checks built-in (and properly
obfuscated if necessary).

Have a look at UrlIdentityPermission and ZoneIdentityPermission.

Thanks,
Fernando

"Matt Budd" <whoami2001ca (AT) yahoo (DOT) ca> wrote

Quote:
Hello all,

I've looked through this newsgroup and saw lots of questions about running
an application from a network drive or a local network. I know that when
you
do this, it puts the assembly into a different "zone" of trust which is
more
restrictive.

In my situation this is a good thing. We don't want to allow our
application
to be run over the network and want to force them to install it (and buy
it)
on each local machine. The problem I'm having is that when you attempt to
run it off the network drive, it dies on you and you get a
System.Security.SecurityException unhandled exception. What I want to do
is
basically catch this exception and then display a readable error message
explaining that it has to be run locally.

I've tried the following code at the very start of my Main() function:
[STAThread]
static void Main(string[] pasArgs)
{
try {
if
(System.Security.SecurityManager.ResolvePolicy(typ eof(frmMain).Assembly.Evid
ence).IsUnrestricted() == false) {
MessageBox.Show("Must run locally!");
return;
}
} catch (System.Security.SecurityException e) {
MessageBox.Show(e.ToString());
return;
}


But I still get the exception and neither of my messageboxes show. Any
ideas
how to catch this exception?

- Matt





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.