Solved

Registry.RegistryConnect

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now