Solved

Registry.RegistryConnect

Posted on 2002-06-17
4
285 Views
Last Modified: 2010-04-04
I am trying to access a list of SID values on a remote server using TRegistry. This is the code:

Uses Registry;

procedure MyProc;
var
  MySList : TStringList;
  MyReg : TRegistry;
  i : Integer;
begin
  MyReg := TRegistry.Create;
  If MyReg.RegistryConnect('\\RemoteServer') then
  begin
    If MyReg.OpenKeyReadOnly('\HKEY_USERS') then
    begin
      MySlist := TStringList.Create;
      MyReg.GetKeyNames(MySList);
      {Do Something with the string list}
      MyReg.CloseKey;
      MySList.Free;
    end
    else
    ShowMessage('Cannot read HKEY_USERS on remote server');
  end;
  MyReg.Free;
end;

I receive the error that the key cannot be read. I can access these values using a component I downloaded. Unfortunately the component does not have the functionality to read key values- which I need later.
The 3rd party component allows a username and password to be provided for the remote server, I think this problem I am having could be a security one.
Could someone please inform me if this is the case or let me know if I am doing something else wrong. If this is a security problem then does anyone know how I can provide a username and password before connecting to the remote registry.
0
Comment
Question by:Rabster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 

Author Comment

by:Rabster
ID: 7083759
I have just realisted, with a bit of tinkering, that when I use registry connect my rootkey is as follows:

\\RemoteServer\HK_CURRENT_USER\{MYSID}

Does anyone know I can change the root key to
\\RemoteServer\HK_USERS

Using MyReg.Rootkey := HK_USERS would set it back to the local machine.
0
 

Author Comment

by:Rabster
ID: 7083773
I have just realisted, with a bit of tinkering, that when I use registry connect my rootkey is as follows:

\\RemoteServer\HK_CURRENT_USER\{MYSID}

Does anyone know I can change the root key to
\\RemoteServer\HK_USERS

Using MyReg.Rootkey := HK_USERS would set it back to the local machine.
0
 
LVL 3

Accepted Solution

by:
raidos earned 50 total points
ID: 7083831
From Delphi help:

Note:     Before calling RegistryConnect, an application must set the RootKey property for its registry object to HKEY_USERS or HKEY_LOCAL_MACHINE.

//Otherwise it will revert back to the Local machine.

Regards
//raidos
0
 

Author Comment

by:Rabster
ID: 7083851
I've been looking at this problem all day and the answer has been staring my right in the face. In the examples I done earlier the first bit of code I wrote after creating the registry wrapper was to set the rootkey to HKey_Users. In my last example I forgot to do this.
Thanks fo your help, the program is working now.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question