473,583 Members | 4,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HKEY_LOCAL_MACH INE Registry Access

I'm attempting some remote registry manipulation via C#. I've written a test
app to simply grab a specified key from a specified hive on a specified
machine. The call to OpenSubKey is throwing System.Security Exception.

Also of note: Sitting at my local box, I can open regedit and connect to the
remote registry. I see three hives: _CLASSES_ROOT, _LOCAL_MACHINE, and
_USERS. I can open all but HKEY_LOCAL_MACH INE. When I try to expand that one,
I get a simple error message that tells me almost nothing.

So I'm fairly certain I'm running up against some kind of permissions issue.
This is a dev server, but I still don't want to go mucking around too much
without knowing what I'm doing. Via Terminal Services, I added LOCAL SERVICE
to HKEY_LOCAL_MACH INE and a few sub keys. That didn't help. I also found two
interesting entries in the Local Security Polcy: Remotely accessible registry
paths and Remotely accesible registry paths and sub-paths. I didn't mess
around with those much, but I did notice that there's no hive on any of the
entries, and it doesn't LOOK like all of the paths I can see connecting
remotely via regedit are in those lists (but I could be wrong).

So what's the magic formula for accessing these keys remotely? And are some
of them tied down by default? I don't think anyone here specifically decided
to make the local_machine hive inaccessible remotely...

Here's some details:
My Machine: Windows 2000 Professional
Remote Machine: Windows 2003 Server
I'm an admin on both machines...

Just for fun, here's a code sample:

public static RegistryKey GetKey(Registry Hive hive, string key, string server)
{
RegistryKey parentKey;
RegistryKey returnKey = null;

if (server == null || server.Length == 0)
{
server = string.Empty;
}

parentKey = RegistryKey.Ope nRemoteBaseKey( hive, server);
if (parentKey != null)
{
try
{
// THE LINE BELOW THROWS
//
System.Security Exception

returnKey = parentKey.OpenS ubKey(key, true);
}
catch(Exception exception)
{
// handle the exception!
returnKey = null;
}

}

return returnKey;
}

Nov 17 '05 #1
21 10792

"Kevin Swanson" <ke**********@n ospam.nospam> wrote in message
news:2F******** *************** ***********@mic rosoft.com...
I'm attempting some remote registry manipulation via C#. I've written a
test
app to simply grab a specified key from a specified hive on a specified
machine. The call to OpenSubKey is throwing System.Security Exception.

Also of note: Sitting at my local box, I can open regedit and connect to
the
remote registry. I see three hives: _CLASSES_ROOT, _LOCAL_MACHINE, and
_USERS. I can open all but HKEY_LOCAL_MACH INE. When I try to expand that
one,
I get a simple error message that tells me almost nothing.

So I'm fairly certain I'm running up against some kind of permissions
issue.
This is a dev server, but I still don't want to go mucking around too much
without knowing what I'm doing. Via Terminal Services, I added LOCAL
SERVICE
to HKEY_LOCAL_MACH INE and a few sub keys. That didn't help. I also found
two
interesting entries in the Local Security Polcy: Remotely accessible
registry
paths and Remotely accesible registry paths and sub-paths. I didn't mess
around with those much, but I did notice that there's no hive on any of
the
entries, and it doesn't LOOK like all of the paths I can see connecting
remotely via regedit are in those lists (but I could be wrong).

So what's the magic formula for accessing these keys remotely? And are
some
of them tied down by default? I don't think anyone here specifically
decided
to make the local_machine hive inaccessible remotely...

Here's some details:
My Machine: Windows 2000 Professional
Remote Machine: Windows 2003 Server
I'm an admin on both machines...

Just for fun, here's a code sample:

public static RegistryKey GetKey(Registry Hive hive, string key, string
server)
{
RegistryKey parentKey;
RegistryKey returnKey = null;

if (server == null || server.Length == 0)
{
server = string.Empty;
}

parentKey = RegistryKey.Ope nRemoteBaseKey( hive, server);
if (parentKey != null)
{
try
{
// THE LINE BELOW THROWS
//
System.Security Exception

returnKey = parentKey.OpenS ubKey(key, true);
}
catch(Exception exception)
{
// handle the exception!
returnKey = null;
}

}

return returnKey;
}


You need to be an admininistrator on the remote machine for this to work.

Willy.
Nov 17 '05 #2
yeah... I'm an admin on both machines.

"Willy Denoyette [MVP]" wrote:

"Kevin Swanson" <ke**********@n ospam.nospam> wrote in message
news:2F******** *************** ***********@mic rosoft.com...
I'm attempting some remote registry manipulation via C#. I've written a
test
app to simply grab a specified key from a specified hive on a specified
machine. The call to OpenSubKey is throwing System.Security Exception.

Also of note: Sitting at my local box, I can open regedit and connect to
the
remote registry. I see three hives: _CLASSES_ROOT, _LOCAL_MACHINE, and
_USERS. I can open all but HKEY_LOCAL_MACH INE. When I try to expand that
one,
I get a simple error message that tells me almost nothing.

So I'm fairly certain I'm running up against some kind of permissions
issue.
This is a dev server, but I still don't want to go mucking around too much
without knowing what I'm doing. Via Terminal Services, I added LOCAL
SERVICE
to HKEY_LOCAL_MACH INE and a few sub keys. That didn't help. I also found
two
interesting entries in the Local Security Polcy: Remotely accessible
registry
paths and Remotely accesible registry paths and sub-paths. I didn't mess
around with those much, but I did notice that there's no hive on any of
the
entries, and it doesn't LOOK like all of the paths I can see connecting
remotely via regedit are in those lists (but I could be wrong).

So what's the magic formula for accessing these keys remotely? And are
some
of them tied down by default? I don't think anyone here specifically
decided
to make the local_machine hive inaccessible remotely...

Here's some details:
My Machine: Windows 2000 Professional
Remote Machine: Windows 2003 Server
I'm an admin on both machines...

Just for fun, here's a code sample:

public static RegistryKey GetKey(Registry Hive hive, string key, string
server)
{
RegistryKey parentKey;
RegistryKey returnKey = null;

if (server == null || server.Length == 0)
{
server = string.Empty;
}

parentKey = RegistryKey.Ope nRemoteBaseKey( hive, server);
if (parentKey != null)
{
try
{
// THE LINE BELOW THROWS
//
System.Security Exception

returnKey = parentKey.OpenS ubKey(key, true);
}
catch(Exception exception)
{
// handle the exception!
returnKey = null;
}

}

return returnKey;
}


You need to be an admininistrator on the remote machine for this to work.

Willy.

Nov 17 '05 #3
A local admin cannot be admin on two different machines unless it's a shadow
account, that is the credentials (account/password) are the same. Is this
the case?
Willy.

"Kevin Swanson" <ke**********@n ospam.nospam> wrote in message
news:DF******** *************** ***********@mic rosoft.com...
yeah... I'm an admin on both machines.

"Willy Denoyette [MVP]" wrote:

"Kevin Swanson" <ke**********@n ospam.nospam> wrote in message
news:2F******** *************** ***********@mic rosoft.com...
> I'm attempting some remote registry manipulation via C#. I've written a
> test
> app to simply grab a specified key from a specified hive on a specified
> machine. The call to OpenSubKey is throwing System.Security Exception.
>
> Also of note: Sitting at my local box, I can open regedit and connect
> to
> the
> remote registry. I see three hives: _CLASSES_ROOT, _LOCAL_MACHINE, and
> _USERS. I can open all but HKEY_LOCAL_MACH INE. When I try to expand
> that
> one,
> I get a simple error message that tells me almost nothing.
>
> So I'm fairly certain I'm running up against some kind of permissions
> issue.
> This is a dev server, but I still don't want to go mucking around too
> much
> without knowing what I'm doing. Via Terminal Services, I added LOCAL
> SERVICE
> to HKEY_LOCAL_MACH INE and a few sub keys. That didn't help. I also
> found
> two
> interesting entries in the Local Security Polcy: Remotely accessible
> registry
> paths and Remotely accesible registry paths and sub-paths. I didn't
> mess
> around with those much, but I did notice that there's no hive on any of
> the
> entries, and it doesn't LOOK like all of the paths I can see connecting
> remotely via regedit are in those lists (but I could be wrong).
>
> So what's the magic formula for accessing these keys remotely? And are
> some
> of them tied down by default? I don't think anyone here specifically
> decided
> to make the local_machine hive inaccessible remotely...
>
> Here's some details:
> My Machine: Windows 2000 Professional
> Remote Machine: Windows 2003 Server
> I'm an admin on both machines...
>
> Just for fun, here's a code sample:
>
> public static RegistryKey GetKey(Registry Hive hive, string key, string
> server)
> {
> RegistryKey parentKey;
> RegistryKey returnKey = null;
>
> if (server == null || server.Length == 0)
> {
> server = string.Empty;
> }
>
> parentKey = RegistryKey.Ope nRemoteBaseKey( hive, server);
>
>
> if (parentKey != null)
> {
> try
> {
> // THE LINE BELOW THROWS
> //
> System.Security Exception
>
> returnKey = parentKey.OpenS ubKey(key, true);
> }
> catch(Exception exception)
> {
> // handle the exception!
> returnKey = null;
> }
>
> }
>
> return returnKey;
> }
>


You need to be an admininistrator on the remote machine for this to work.

Willy.

Nov 17 '05 #4
Okay, one of is is obviously not understanding something. Probably it's me.

Using Regedit: I'm sitting at my local machine, logged on under my network
account. I pull up regedit, click Registyr/Connect Network Registry, and type
in the remote server name. At this point, I can see the HKLM hive, but I get
an error when I try to open it.

Programmaticall y: Running an app on my local machine, I succeed when calling
RegistryKey.Ope nRemoteBaseKey, but fail when calling OpenSubKey.

So... I don't understand where the local accounts come into play (unless
you're talking about the LOCAL SERVICE account).

"Willy Denoyette [MVP]" wrote:
A local admin cannot be admin on two different machines unless it's a shadow
account, that is the credentials (account/password) are the same. Is this
the case?
Willy.

"Kevin Swanson" <ke**********@n ospam.nospam> wrote in message
news:DF******** *************** ***********@mic rosoft.com...
yeah... I'm an admin on both machines.

"Willy Denoyette [MVP]" wrote:

"Kevin Swanson" <ke**********@n ospam.nospam> wrote in message
news:2F******** *************** ***********@mic rosoft.com...
> I'm attempting some remote registry manipulation via C#. I've written a
> test
> app to simply grab a specified key from a specified hive on a specified
> machine. The call to OpenSubKey is throwing System.Security Exception.
>
> Also of note: Sitting at my local box, I can open regedit and connect
> to
> the
> remote registry. I see three hives: _CLASSES_ROOT, _LOCAL_MACHINE, and
> _USERS. I can open all but HKEY_LOCAL_MACH INE. When I try to expand
> that
> one,
> I get a simple error message that tells me almost nothing.
>
> So I'm fairly certain I'm running up against some kind of permissions
> issue.
> This is a dev server, but I still don't want to go mucking around too
> much
> without knowing what I'm doing. Via Terminal Services, I added LOCAL
> SERVICE
> to HKEY_LOCAL_MACH INE and a few sub keys. That didn't help. I also
> found
> two
> interesting entries in the Local Security Polcy: Remotely accessible
> registry
> paths and Remotely accesible registry paths and sub-paths. I didn't
> mess
> around with those much, but I did notice that there's no hive on any of
> the
> entries, and it doesn't LOOK like all of the paths I can see connecting
> remotely via regedit are in those lists (but I could be wrong).
>
> So what's the magic formula for accessing these keys remotely? And are
> some
> of them tied down by default? I don't think anyone here specifically
> decided
> to make the local_machine hive inaccessible remotely...
>
> Here's some details:
> My Machine: Windows 2000 Professional
> Remote Machine: Windows 2003 Server
> I'm an admin on both machines...
>
> Just for fun, here's a code sample:
>
> public static RegistryKey GetKey(Registry Hive hive, string key, string
> server)
> {
> RegistryKey parentKey;
> RegistryKey returnKey = null;
>
> if (server == null || server.Length == 0)
> {
> server = string.Empty;
> }
>
> parentKey = RegistryKey.Ope nRemoteBaseKey( hive, server);
>
>
> if (parentKey != null)
> {
> try
> {
> // THE LINE BELOW THROWS
> //
> System.Security Exception
>
> returnKey = parentKey.OpenS ubKey(key, true);
> }
> catch(Exception exception)
> {
> // handle the exception!
> returnKey = null;
> }
>
> }
>
> return returnKey;
> }
>

You need to be an admininistrator on the remote machine for this to work.

Willy.


Nov 17 '05 #5

"Kevin Swanson" <ke**********@n ospam.nospam> wrote in message
news:67******** *************** ***********@mic rosoft.com...
Okay, one of is is obviously not understanding something. Probably it's
me.

Using Regedit: I'm sitting at my local machine, logged on under my
network
account. I pull up regedit, click Registyr/Connect Network Registry, and
type
in the remote server name. At this point, I can see the HKLM hive, but I
get
an error when I try to open it.

Programmaticall y: Running an app on my local machine, I succeed when
calling
RegistryKey.Ope nRemoteBaseKey, but fail when calling OpenSubKey.

So... I don't understand where the local accounts come into play (unless
you're talking about the LOCAL SERVICE account).


<logged on under my network account...>, does it mean you are logged on
using a DOMAIN account (I guess not), or a local account?
You said you were an administrator on both machines, right? This can only be
true if:
- you are logged on using a DOMAIN administrators account that is a member
of the remote and the local machines administrators group, or
- you are logged on as a local administrator who has a shadow account on the
remote machine.
A shadows account is an account with the same credentials
(username/password) having the same privileges (so a member of
administrators in your case).

Hope it clears things up now,

Willy.


Nov 17 '05 #6
Willy,

Sorry it's taken so long for a reply. Somehow I didn't receive notice that
you had replied.

I'm signed into a domain account. The domain account is an admin on both
machines.

"Willy Denoyette [MVP]" wrote:

"Kevin Swanson" <ke**********@n ospam.nospam> wrote in message
news:67******** *************** ***********@mic rosoft.com...
Okay, one of is is obviously not understanding something. Probably it's
me.

Using Regedit: I'm sitting at my local machine, logged on under my
network
account. I pull up regedit, click Registyr/Connect Network Registry, and
type
in the remote server name. At this point, I can see the HKLM hive, but I
get
an error when I try to open it.

Programmaticall y: Running an app on my local machine, I succeed when
calling
RegistryKey.Ope nRemoteBaseKey, but fail when calling OpenSubKey.

So... I don't understand where the local accounts come into play (unless
you're talking about the LOCAL SERVICE account).


<logged on under my network account...>, does it mean you are logged on
using a DOMAIN account (I guess not), or a local account?
You said you were an administrator on both machines, right? This can only be
true if:
- you are logged on using a DOMAIN administrators account that is a member
of the remote and the local machines administrators group, or
- you are logged on as a local administrator who has a shadow account on the
remote machine.
A shadows account is an account with the same credentials
(username/password) having the same privileges (so a member of
administrators in your case).

Hope it clears things up now,

Willy.


Nov 17 '05 #7
Hi Kevin,

If you logon on the remote machine using the same domain account, can to
access the registry key? Also, please check if the user has full control to
the registry key and wasn't denied access to it.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #8
KY,

Yeah... I can log on to the remote machine using my domain account, and get
full access to the registry. But I can't open HKLM using regedit from my
machine (same domain account) and connecting to the remote machine. I can see
the hive, but can't open it.

"Kevin Yu [MSFT]" wrote:
Hi Kevin,

If you logon on the remote machine using the same domain account, can to
access the registry key? Also, please check if the user has full control to
the registry key and wasn't denied access to it.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #9
Hi Kevin,

Looking at the nature of this issue, it would require intensive
troubleshooting which would be done quickly and effectively with direct
assistance from a Microsoft Support Professional through Microsoft Product
Support Services. You can contact Microsoft Product Support directly to
discuss additional support options you may have available, by contacting us
at 1-(800)936-5800 or by choosing one of the options listed at
http://support.microsoft.com/default...d=sz;en-us;top.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3218
by: g82martin | last post by:
I am using the RegistryKey class to access the registry on remote machines. I only require read access. I am able to successfully read registry keys under HKLM\Software\Microsoft\Windows NT\CurrentVersion\HotFix but I get a permissions error when I try to access HKLM\Software\Network Associates\TVD\Shared Components\VirusScan Engine\4.0.xx....
0
1195
by: Kovan A. | last post by:
Steps i have taken: 1. Gave ASPNET user access to C:\WINDOWS\system32\config\appevent.evt 2. Set my anonymous asp user to Administrator (to eliminate any problesm with reading and writing) 3. created a key called HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\TE ST (suggested by MS KB) I am still having this...
11
3567
by: Josh Flanagan | last post by:
I am trying to write to the event log from ASP.NET, on Windows XP SP1. As soon as I try to write an event (or even query the source with EventLog.SourceExists() or EventLog.LogNameFromSourceName()) I get a SecurityException "Requested registry access is not allowed.". I have read the KB article associated with this error message, which...
3
2496
by: bfprog | last post by:
Using IBM iSeries client access OLEDB provider to connect to DB2 on AS/400, but cannot create connection using .NET web app. Using following code: Dim cnTest As New OleDbConnection("Provider=IBMDA400; Data Source=S10324NM; User ID=THEUSER; Password=THESECRET") Works fine in console app, but fails in web app with: ...
4
46421
by: LP | last post by:
Hi, My webservice is currently deployed on WIndows 2000 server and runs pretty fine. I am trying to run my webservice on a Windows 2003 server. My webservice tries to write to a eventlog. The code is as follows: System.Diagnostics.EventLog Log = new System.Diagnostics.EventLog( EventLogName ); Log.Source = EventLogName; Log.WriteEntry(...
6
9003
by: Boris | last post by:
Has anyone ever managed to read a Windows registry key in a PHP webpage? I installed the PHP extension win32std and saved their sample script from http://wildphp.free.fr/wiki/doku.php?id=win32std:index#registry_access as a webpage. However when I open the webpage (PHP 5.1.2, Windows Server 2003, IIS 6) I get the error message "Warning: Can't...
7
12081
by: Peter Ritchie | last post by:
I'm writing a Web Service and I would like to add performance counter data for monitoring performance of the Web Service's operations over time and load. The problem is, I get the "Requested registry access is not allowed." SecurityException when I try and create the performance counter category via PerformanceCounterCategory.Create(). I...
1
3130
by: UK1967 | last post by:
I wrote a ASP.NET application (Windows 2003 Enterprise Server, IIS, .NET Framework 1.1). This application use the Windows (AD) account and impersonation. Some functions in this application contact, read and change the remote registry (HKLM/Software/...) of some internal server. After installing SP1 on the web server (IIS) all functions with...
3
8312
by: JB | last post by:
I am trying to access a registry key on computer like so: key = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, computerName).OpenSubKey(Subkey); There are two keys I am trying to read, 1 works, and the other gives me the "Requested registry access is not allowed." i've narrowed it down to...
0
7894
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7825
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7933
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8191
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5700
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3816
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3841
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1431
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.