HKEY_LOCAL_MACHINE注册表访问 [英] HKEY_LOCAL_MACHINE Registry Access

查看:117
本文介绍了HKEY_LOCAL_MACHINE注册表访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过C#尝试一些远程注册表操作。我已经编写了一个测试

的应用程序,只需从指定的

机器上的指定配置单元中获取指定的密钥。对OpenSubKey的调用是抛出System.SecurityException。


还有一点需要注意:坐在我本地的盒子里,我可以打开注册表并连接到

远程注册表。我看到三个配置单元:_CLASSES_ROOT,_LOCAL_MACHINE和

_USERS。我可以打开除HKEY_LOCAL_MACHINE以外的所有内容。当我尝试扩展那个时,

我收到一条简单的错误消息,告诉我几乎什么都没有。


所以我很确定我''正在遇到某种权限问题。

这是一个开发服务器,但我还是不想过多地瞎逛

而不知道我是什么我在做。通过终端服务,我向HKEY_LOCAL_MACHINE和一些子键添加了LOCAL SERVICE

。那没有用。我还在Local Security Polcy中找到了两个有趣的条目:远程访问的注册表

路径和远程可访问的注册表路径和子路径。我并没有把这些东西弄得很糟糕,但我确实注意到任何一个

条目都没有蜂巢,而且它没有看起来像我可以看到的所有路径连接

远程通过regedit在这些列表中(但我可能是错的)。


那么'是什么'远程访问这些密钥的神奇公式?还有一些

他们默认绑定了吗?我不认为这里的任何人明确决定

使远程无法访问local_machine hive ...


这里有一些细节:

我的机器:Windows 2000专业版

远程机器:Windows 2003 Server

我是两台机器上的管理员...


只是为了好玩,这里是一个代码示例:


public static RegistryKey GetKey(RegistryHive hive,string key,string server)

{

RegistryKey parentKey;

RegistryKey returnKey = null;


if(server == null || server.Length == 0)

{

server = string.Empty;

}


parentKey = RegistryKey.OpenRemoteBaseKey(hive,server);

if(parentKey!= null)

{

try

{

//下面的线路

//

System.SecurityException


returnKey = parentKey.OpenSubKey(key,true);

}

catch (异常例外)

{

//处理异常!

returnKey = null;

}


}


返回returnKey;

}

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.SecurityException.

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_MACHINE. 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_MACHINE 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(RegistryHive hive, string key, string server)
{
RegistryKey parentKey;
RegistryKey returnKey = null;

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

parentKey = RegistryKey.OpenRemoteBaseKey(hive, server);
if (parentKey != null)
{
try
{
// THE LINE BELOW THROWS
//
System.SecurityException

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

}

return returnKey;
}

推荐答案



" Kevin Swanson" <柯********** @ nospam.nospam>在消息中写道

新闻:2F ********************************** @ microsof t.com ...

"Kevin Swanson" <ke**********@nospam.nospam> wrote in message
news:2F**********************************@microsof t.com...
我正在尝试通过C#进行一些远程注册表操作。我已经编写了一个
测试应用程序,只需从指定的
机器上的指定配置单元中获取指定的键。对OpenSubKey的调用是抛出System.SecurityException。

另外值得注意的是:坐在我本地的盒子里,我可以打开注册表并连接到
远程注册表。我看到三个配置单元:_CLASSES_ROOT,_LOCAL_MACHINE和
_USERS。我可以打开除HKEY_LOCAL_MACHINE以外的所有内容。当我试图扩展那个
时,我得到一条简单的错误信息,几乎什么也没告诉我。

所以我很确定我正在反对某种权限
问题。
这是一个开发服务器,但我仍然不想过多地瞎逛
而不知道我在做什么。通过终端服务,我向HKEY_LOCAL_MACHINE和一些子键添加了LOCAL
SERVICE
。那没有用。我还在Local Security Polcy中找到了两个有趣的条目:远程可访问的注册表路径和远程可访问的注册表路径和子路径。我并没有把这些东西弄得一团糟,但是我确实注意到任何
条目都没有蜂巢,它并不像所有的那样我可以看到通过注册表远程连接的路径在那些列表中(但我可能是错的)。

那么远程访问这些密钥的神奇公式是什么?是否有一些他们默认绑定了?我不认为这里的任何人特别决定
使local_machine hive远程无法进入......

这里有一些细节:
我的机器: Windows 2000 Professional
远程计算机:Windows 2003 Server
我是两台计算机上的管理员...

只是为了好玩,这里有一个代码示例:

public static RegistryKey GetKey(RegistryHive hive,string key,string
服务器)
{/; RegistryKey parentKey;
RegistryKey returnKey = null;

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

parentKey = RegistryKey。 OpenRemoteBaseKey(配置单元,服务器);

if(parentKey!= null)
{
尝试
//
下面的线 //
System.SecurityException

returnKey = parentKey.OpenSubKey(key,true);
}
catch(异常异常)
{
处理异常!
returnKey = null;
}


返回returnKey;
}
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.SecurityException.

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_MACHINE. 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_MACHINE 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(RegistryHive hive, string key, string
server)
{
RegistryKey parentKey;
RegistryKey returnKey = null;

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

parentKey = RegistryKey.OpenRemoteBaseKey(hive, server);
if (parentKey != null)
{
try
{
// THE LINE BELOW THROWS
//
System.SecurityException

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

}

return returnKey;
}




你需要成为远程机器上的管理员才能工作。


Willy。



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

Willy.


是啊......我两个机器上的管理员。


Willy Denoyette [MVP]"写道:
yeah... I''m an admin on both machines.

"Willy Denoyette [MVP]" wrote:

" Kevin Swanson" <柯********** @ nospam.nospam>在消息中写道
新闻:2F ********************************** @ microsof t.com。 ..

"Kevin Swanson" <ke**********@nospam.nospam> wrote in message
news:2F**********************************@microsof t.com...
我正在尝试通过C#进行一些远程注册表操作。我已经编写了一个
测试应用程序,只需从指定的
机器上的指定配置单元中获取指定的键。对OpenSubKey的调用是抛出System.SecurityException。

另外值得注意的是:坐在我本地的盒子里,我可以打开注册表并连接到
远程注册表。我看到三个配置单元:_CLASSES_ROOT,_LOCAL_MACHINE和
_USERS。我可以打开除HKEY_LOCAL_MACHINE以外的所有内容。当我试图扩展那个
时,我得到一条简单的错误信息,几乎什么也没告诉我。

所以我很确定我正在反对某种权限
问题。
这是一个开发服务器,但我仍然不想过多地瞎逛
而不知道我在做什么。通过终端服务,我向HKEY_LOCAL_MACHINE和一些子键添加了LOCAL
SERVICE
。那没有用。我还在Local Security Polcy中找到了两个有趣的条目:远程可访问的注册表路径和远程可访问的注册表路径和子路径。我并没有把这些东西弄得一团糟,但是我确实注意到任何
条目都没有蜂巢,它并不像所有的那样我可以看到通过注册表远程连接的路径在那些列表中(但我可能是错的)。

那么远程访问这些密钥的神奇公式是什么?是否有一些他们默认绑定了?我不认为这里的任何人特别决定
使local_machine hive远程无法进入......

这里有一些细节:
我的机器: Windows 2000 Professional
远程计算机:Windows 2003 Server
我是两台计算机上的管理员...

只是为了好玩,这里有一个代码示例:

public static RegistryKey GetKey(RegistryHive hive,string key,string
服务器)
{/; RegistryKey parentKey;
RegistryKey returnKey = null;

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

parentKey = RegistryKey。 OpenRemoteBaseKey(配置单元,服务器);

if(parentKey!= null)
{
尝试
//
下面的线 //
System.SecurityException

returnKey = parentKey.OpenSubKey(key,true);
}
catch(异常异常)
{
处理异常!
returnKey = null;
}


返回returnKey;
}
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.SecurityException.

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_MACHINE. 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_MACHINE 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(RegistryHive hive, string key, string
server)
{
RegistryKey parentKey;
RegistryKey returnKey = null;

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

parentKey = RegistryKey.OpenRemoteBaseKey(hive, server);
if (parentKey != null)
{
try
{
// THE LINE BELOW THROWS
//
System.SecurityException

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

}

return returnKey;
}



你需要成为这是远程机器上的管理员。

Willy。



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

Willy.



本地管理员不能是管理员在两台不同的机器上,除非它是影子

帐户,即凭证(帐户/密码)是相同的。这是

的情况吗?

Willy。


" Kevin Swanson" <柯********** @ nospam.nospam>在消息中写道

新闻:DF ********************************** @ microsof t.com ...
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**********@nospam.nospam> wrote in message
news:DF**********************************@microsof t.com...
是的...我是两台机器上的管理员。

Willy Denoyette [MVP]"写道:
yeah... I''m an admin on both machines.

"Willy Denoyette [MVP]" wrote:

" Kevin Swanson" <柯********** @ nospam.nospam>在消息中写道
新闻:2F ********************************** @ microsof t.com。 ..

"Kevin Swanson" <ke**********@nospam.nospam> wrote in message
news:2F**********************************@microsof t.com...
>我正在尝试通过C#进行远程注册表操作。我写了一个
>测试
>应用程序只是从指定的配置单元中获取指定的密钥
>机。对OpenSubKey的调用是抛出System.SecurityException。
>
>还要注意:坐在我当地的盒子里,我可以打开注册表并连接
>到
>
>远程注册表。我看到三个配置单元:_CLASSES_ROOT,_LOCAL_MACHINE和
> _USERS。我可以打开除HKEY_LOCAL_MACHINE以外的所有内容。当我尝试扩展
>
>一,
>我收到一条简单的错误消息,几乎没有告诉我任何事情。
>
>所以我很确定我正在反对某种权限
>问题。
>这是一个开发服务器,但我仍然不想去乱搞
>很多
>不知道我在做什么。通过终端服务,我添加了LOCAL
>服务
>到HKEY_LOCAL_MACHINE和一些子键。那没有用。我也
>发现
>两个
>本地安全政策中有趣的条目:远程访问
>注册表
>路径和可远程访问的注册表路径和子路径。我没有
>一团糟
>那些很多,但我注意到任何
>都没有蜂巢。
>条目,它并不像我能看到的所有路径连接
>远程通过注册表在那些列表中(但我可能是错的)。
>
>那么远程访问这些密钥的神奇公式是什么?
>一些
>他们默认绑定了吗?我不认为这里的任何人具体
>决定
>使local_machine配置远程无法访问...
>
>这里有一些细节:
>我的机器:Windows 2000专业版
>远程计算机:Windows 2003 Server
>我是两台机器上的管理员...
>
>只是为了好玩,这里是一个代码示例:
>
> public static RegistryKey GetKey(RegistryHive hive,string key,string
> server)
> {
> RegistryKey parentKey;
> RegistryKey returnKey = null;
>
> if(server == null || server.Length == 0)
> {
> server = string.Empty;
> }
>
> parentKey = RegistryKey.OpenRemoteBaseKey(hive,server);
>
>
> if(parentKey!= null)
> {
>试试
> {
> //下面的线路
> //
> System.SecurityException
>
> returnKey = parentKey.OpenSubKey(key,true);
> }
> catch(异常例外)
> {
> //处理异常!
> returnKey = null;
> }
>
> }
>
> return returnKey;
> }
>
> 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.SecurityException.
>
> 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_MACHINE. 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_MACHINE 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(RegistryHive hive, string key, string
> server)
> {
> RegistryKey parentKey;
> RegistryKey returnKey = null;
>
> if (server == null || server.Length == 0)
> {
> server = string.Empty;
> }
>
> parentKey = RegistryKey.OpenRemoteBaseKey(hive, server);
>
>
> if (parentKey != null)
> {
> try
> {
> // THE LINE BELOW THROWS
> //
> System.SecurityException
>
> returnKey = parentKey.OpenSubKey(key, true);
> }
> catch(Exception exception)
> {
> // handle the exception!
> returnKey = null;
> }
>
> }
>
> return returnKey;
> }
>



你需要成为远程机器上的管理员才能工作。

Willy。



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

Willy.



这篇关于HKEY_LOCAL_MACHINE注册表访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆