Groups | Blog | Home
all groups > dotnet clr > november 2007 >

dotnet clr : Query permissions for System.Net


Gene Chang
11/15/2007 8:52:12 AM
I am writing an application where I obtain the IP address of the local
adapter. When the user is logged in as Guest, this call fails with an
exception: Access to the path 'Global\.net clr networking' is denied

I think this is because the guest user is not allowed to access
System.Net.

How do I query if the current user is allowed ot use certain
assemblies or modules? For example, my networking functionality.

Thanks.

Peter Ritchie [C# MVP]
11/17/2007 10:23:00 AM
That looks more like a perf counter or a named mutex.

Without knowing what method you've called it's hard to answer this question
exactly.

If it's a perf counter, the user must have the required access (which we
don't know). If it's a named mutex, whatever is creating the mutex must give
access to the current user. Again, since we don't know what you're calling
we can't tell how to discern if the current user has the required access to
do what you want.

Most method list the security requirements need in order to call them. You
can either add a try/catch(SecurityException) block around the code that may
not have access, or if you know the specific security permission that is
required you can create an instance of that type and call its Demand method
with a try/catch(SecurityException)--which would ensure things don't get into
an unknown state.

--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#


[quoted text, click to view]
Günter Prossliner
11/19/2007 9:06:15 AM
Hallo!

[quoted text, click to view]

It is a Performance-Counter
(HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\.NET CLR Networking).

The error-message ("Acces to path ... denied") sounds like the caller
doesn't hold the nessersary "unmanaged Permission" (ACLs).



GP

AddThis Social Bookmark Button