Accessing the regsitry via a service

J

Jay

Here lies my quandry:

I have written a service that makes registry changes.

The problem I run into is that, if I create the service under any
account other than 'User' (i.e. 'LocalSystem', 'LocalService'), access
to the registry is denied. If I create the service under the 'User'
account, any time the user changes his network password (which is
vigorously mandated in my workplace) he must also change it for the
service.

I have done some research, and my best bet seems to be impersonating
the current user, since every user has administrative priveleges.
However, all examples I have located are either in ASP.NET or VB 6.0.
 
I

irfan

hi,

I could accomplish the same....

but I'm not sure if you are trying to access a registry of
a different PC...

irfan
 
G

Girish Bharadwaj

Jay said:
Here lies my quandry:

I have written a service that makes registry changes.

The problem I run into is that, if I create the service under any
account other than 'User' (i.e. 'LocalSystem', 'LocalService'), access
to the registry is denied. If I create the service under the 'User'
account, any time the user changes his network password (which is
vigorously mandated in my workplace) he must also change it for the
service.

I have done some research, and my best bet seems to be impersonating
the current user, since every user has administrative priveleges.
However, all examples I have located are either in ASP.NET or VB 6.0.


You can impersonate a user, by using LogonUser() API or I think use the
"Access control APIs' from win32 API list. Of course, for that you might
have to use P/Invoke to use in .NET.
 
J

Jay

Girish Bharadwaj said:
You can impersonate a user, by using LogonUser() API or I think use the
"Access control APIs' from win32 API list. Of course, for that you might
have to use P/Invoke to use in .NET.

I have investigated that, but it appears that I must have a
username/password to use this option. The service must be able to run
without any programmed username/password. If I am mistaken, feel free
to fill me in on proper usage.
 
J

Jay

irfan said:
hi,

I could accomplish the same....

but I'm not sure if you are trying to access a registry of
a different PC...

irfan

I will be accessing the local registry.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top