Hi,
Thanks for your quickly reply!
Comments in line.
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: "Al Kaufman" <
[email protected]>
References: <
[email protected]>
<
[email protected]>
Subject: Re: Registry Permissions
Date: Fri, 20 Feb 2004 09:56:34 -0600
Lines: 92
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <
[email protected]>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: cs24243238-237.austin.rr.com 24.243.238.237
Path: cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA06.phx.gbl!TK2MSFTNGXA0
5.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.vb:183037
X-Tomcat-NG: microsoft.public.dotnet.languages.vb
Peter,
I don't think it makes any difference but my application is a console
application, not a windows application. For clarification purposes, my .NET
application's exe resides on PC A, but that's just a maintenance and
administration convenience. It would be a headache but it could be
installed on each PC. If it is installed on a PC, it runs just fine, i.e.,
there is no problem reading the registry. If the application is installed
on PC A and run from PC B then PC B's registry cannot be read.
From your description, I assume that you application is similar with code
below. That is to say it will not need any other resource, e.g. it do not
need to open an file that is located on PC A, or it hasn't some information
in the registry on PC A particularlly.
Imports Microsoft.Win32
Module Module1
Public Sub Main()
Dim regLocalMachine As RegistryKey =
RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, "sha-phuang-03")
Dim regComputerName As RegistryKey =
Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Control\ComputerN
ame\ComputerName", False)
Console.WriteLine(regComputerName.GetValue("ComputerName"))
End Sub
End Module
Here's where I get confused. When the application is executed from PC B, I
thought it was running on the PC B regardless of the location of the exe. I
didn't think the location of the exe controlled where the application was
running. Are you saying that the application is running on PC A and is
therefore attempting to access the registry on PC B that it considers
remote?
Yes, if an application is located on PC A, and you shared the application
with an UNC path.
If you run the application from PC B, the code will run in PC B.
But .NET framework has a set of security modal(CAS code access security ).
You can specify an application from different place with different security
level. As I said in my last post, Microsoft .NET Framework 1.1
Configuration will help you configurate the permission for the application
from different place. By default, the local machine has the high privilege
to let the code from local machine do the thing which needs high privilege.
While an application from outside the local machine will be given less
privilege, so that when you run the application from another PC will get
the security exception which was thrown by .NET framework.
So to run the application located in PC A from PC B, you must change the
default CAS setting on the PC B as I said in my last post.
For detailed information about .NET Framework Configuration Tool . Take a
look at the link below.
.NET Framework Tools
.NET Framework Configuration Tool (Mscorcfg.msc)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/htm
l/cpconnetframeworkadministrationtoolmscorcfgmsc.asp