Solved

Registry.RegistryConnect

Posted on 2002-06-17
4
284 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 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