Reading Registry with XP_RegRead under System Account

  • I have the following code:

    DECLARE @Store int

    EXECUTE master.dbo.xp_regread 'HKEY_CURRENT_USER',

    'SOFTWARE\VB and VBA Program Settings\eBis\Locations',

    'StoreNumber',

    @Store OUTPUT,

    'no_output'

    Print @Store

    This code works fine on a server that has the SQL Service Account as a domain user but it won't work on one that has the default System Account. I am unable to get the machines that I need to run this on changed to use a domain account.

    If I remove the 'no_output' parameter it gives me an error: "The system cannot find the file specified." otherwise I just get @Store as a null value.

    The permissions on the registry key appear to be the same for the domain account and for the System account.

    Can anyone tell me why this doesn't work on the System account machine or what I need to do to get it to work?

    Thx.

    Don


    If you don't stand for something, you'll fall for anything!,

    Don Urquhart

  • I can't believe no one can solve this for me as I thought this was the best site.

    I really need to resolve this issue for an upcoming project. Any help greatly appreciated.


    If you don't stand for something, you'll fall for anything!,

    Don Urquhart

  • Only sysadmin users on Windows Server can access registry.

    If you cannot change the account your SQL Server is started with you may login not as "sa" but as appropriate Windows user.

    But my advice - DON'T!

    Find another way and get rid of Registry reading.

    This procedure is undocumented and unsupported.

    And very insecure.

    _____________
    Code for TallyGenerator

  • Thanks Sergiy

    I agree it is not the smart thing to do to make the user a sysadmin, especially in this case, and we have found a way around the problem that caused this post.

    Just wanted to find out the reason in case I should ever be forced to use that approach.

    Cheers,


    If you don't stand for something, you'll fall for anything!,

    Don Urquhart

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply