Re: Using the LogonUser API

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Olof Lagerkvist (no_at_email.address)
Date: 10/05/04


Date: Tue, 05 Oct 2004 09:23:10 GMT

Jerry West wrote:

> Thank you, that did solve the issue, sort of. Perhaps what I want to do
> isn't possible. Maybe you can tell me? The solution I am attempting to solve
> using the code posted below is this:
>
> I am the admin of a NT based computer. There are other user accounts on the
> computer which are not admin accounts. I do not always know the passwords to
> these accounts, or, to be more precise, my program does not know the
> passwords to these accounts. This program, which is not running as a
> service, needs to access the user accounts' registry programmically in order
> to read data from them. Is this possible? It seems it is from what I have
> read in the MSDN. However, using the code below I always get a handle to my
> own registry versus the user account's registry that I need. Maybe I am
> passing the wrong credentials? In the Impersonate function below I pass the
> following parameter values:
>
> sUser = the admin account name which is me
> sDomain = the name of the local computer the program is running on
> sPwd = the clear text admin account password
>
> When the LoadProfile call is made I pass for UserAcct the name of the
> account, or profile, that I want to get a handle to. It seems to work, no
> errors and I get a valid handle. Yet the handle is to my own registry and
> not the user's name which I passed. Can you shed some light on what I am
> doing wrong? Is the solution I am trying to solve possible?
>
> Thank you for your consideration.

To load a profile is much more than loading the user's registry.
Therefore, if you only need the registry you do not have to use any
logon at all since the administrator can access the users registries.

If the other user is logged on you can find the users registry settings
under HKEY_USERS\<sid-number-of-user> or if the user is not logged on
you can load the user's registry. The user's registry file is called
ntuser.dat in the user's profile directory and the name of that
directory is saved in HKLM\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\ProfileList. Use RegLoadKey() to load the user's
registry and RegUnloadKey() when you do not need it anymore.

-- 
Olof Lagerkvist
ICQ: 724451
Web page: http://here.is/olof


Relevant Pages

  • Re: Using the LogonUser API
    ... > computer which are not admin accounts. ... > own registry versus the user account's registry that I need. ... > sPwd = the clear text admin account password ... To load a profile is much more than loading the user's registry. ...
    (microsoft.public.vb.general.discussion)
  • Re: OE Hyperlinks do not work
    ... thought that maybe some registry editing may solve my problem. ... the registry randomly so I hope that someone can make a suggestion as to ... My computer has three user accounts, one for me, my wife and my ... Scroll down to URL:HyperText Transfer Protocol and select it. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Help!: Problems with Restricted access accounts
    ... series of business object DLLs that need to be registered on each local ... Our clients have their users set up as Restricted user accounts. ... the user tries again as a restricted access user account, ... seems that the user is unable to "see" the DLL entries in the registry. ...
    (microsoft.public.windowsxp.security_admin)
  • Limited accounts
    ... Said applications run fine under XP if the account ... typically the problem is a registry problem, ... I want to know why limited accounts will ... >two accounts on this computer both administrators at the ...
    (microsoft.public.windowsxp.security_admin)
  • Re: Registry Corruption & OE unable to poll
    ... that OE cannot poll for new messages. ... one of the Hotmail accounts was made. ... The reversal of all manual registry changes was not sufficient to ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)