By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,101 Members | 1,395 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,101 IT Pros & Developers. It's quick & easy.

registry HKEY_LOCAL_MACHINE and user rights

P: n/a
Can my program access the HKEY_LOCAL_MACHINE/Software section of the
registry when being used by a user with restricted rights (not with admin
rights)?

If so, how? I have a program that functions just fine when run by an
administrator but generates an exception when run by a restricted user. The
program accesses the HKEY_LOCAL_MACHINE/Software section to set or get
application settings that are not user specific.

Thanks,

Dennis

Nov 16 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Hi Dennis,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to change the credential to
another user in a winform application. If there is any misunderstanding,
please feel free to let me know.

As far as I know, there isn't such method available in .net framework.
However, we can achieve that with Win32 SDK Call. LogonUser is such an API
that can do this.

http://msdn.microsoft.com/library/de...us/secauthn/se
curity/logonuser.asp

Here is a good KB article, which contains detailed information about how to
do this with implementation code. HTH

http://support.microsoft.com/?id=306158

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #2

P: n/a
Try using this to build impersonation into your program and then run
it.

http://www.codeproject.com/csharp/cpimpersonation1.asp

It might help to just use the source code already provided to see if
you can access the regex. That way you dont have to modify your own
code if it doesnt work, which i doubt.

:-)
Sushant

"Dennis C. Drumm" <de*******@primacode.com> wrote in message news:<#C**************@TK2MSFTNGP09.phx.gbl>...
Can my program access the HKEY_LOCAL_MACHINE/Software section of the
registry when being used by a user with restricted rights (not with admin
rights)?

If so, how? I have a program that functions just fine when run by an
administrator but generates an exception when run by a restricted user. The
program accesses the HKEY_LOCAL_MACHINE/Software section to set or get
application settings that are not user specific.

Thanks,

Dennis

Nov 16 '05 #3

P: n/a
A regular user can only read settings from HKLM, you need to be poweruser or
admin to write values to that part of registry. This is the default,
however, if these are your own settings in your own application you could
make the installation program change the security of your key so regular
users may change values in your application's section.

Another way would be to use a configuration file instead. Although I don't
see why regular users should be allowed to change settings that would effect
all users...
Arild

"Dennis C. Drumm" <de*******@primacode.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Can my program access the HKEY_LOCAL_MACHINE/Software section of the
registry when being used by a user with restricted rights (not with admin
rights)?

If so, how? I have a program that functions just fine when run by an
administrator but generates an exception when run by a restricted user.
The program accesses the HKEY_LOCAL_MACHINE/Software section to set or get
application settings that are not user specific.

Thanks,

Dennis

Nov 16 '05 #4

P: n/a
You should never store volatile application data in HKEY_LOCAL_MACHINE - you are guaranteeing that only administrators will be able to use your program

The appropriate place to put shared data in the registry is exposed via

System.Windows.Forms.Application.CommonAppDataRegi stry

and user data via

System.Windows.Forms.Application.UserAppDataRegist ry

under both of these you should have keys for <companyname>\<product>

this is the standard non-admin required way of storing information in the registry

For storing files there are equivelent areas of the file system exposed by the Application class too.

Regards

Richard Blewett - DevelopMentor

http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<2c**************************@posting.google.com >

Try using this to build impersonation into your program and then run
it.

http://www.codeproject.com/csharp/cpimpersonation1.asp

It might help to just use the source code already provided to see if
you can access the regex. That way you dont have to modify your own
code if it doesnt work, which i doubt.

:-)
Sushant

"Dennis C. Drumm" <de*******@primacode.com> wrote in message news:<#C**************@TK2MSFTNGP09.phx.gbl>...
Can my program access the HKEY_LOCAL_MACHINE/Software section of the
registry when being used by a user with restricted rights (not with admin
rights)?

If so, how? I have a program that functions just fine when run by an
administrator but generates an exception when run by a restricted user. The
program accesses the HKEY_LOCAL_MACHINE/Software section to set or get
application settings that are not user specific.

Thanks,

Dennis


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004

[microsoft.public.dotnet.languages.csharp]
Nov 16 '05 #5

P: n/a
Thanks to everyone for the responses.

Richard, since the Application.CommonAppDataRegistry puts information in a
key associated with an application version, is there a way to retrieve
common user data from keys created for previous versions of the application?

Thanks,

Dennis

"Richard Blewett [DevelopMentor]" <ri******@develop.com> wrote in message
news:OO**************@tk2msftngp13.phx.gbl...
You should never store volatile application data in HKEY_LOCAL_MACHINE -
you are guaranteeing that only administrators will be able to use your
program

The appropriate place to put shared data in the registry is exposed via

System.Windows.Forms.Application.CommonAppDataRegi stry

and user data via

System.Windows.Forms.Application.UserAppDataRegist ry

under both of these you should have keys for <companyname>\<product>

this is the standard non-admin required way of storing information in the
registry

For storing files there are equivelent areas of the file system exposed by
the Application class too.

Regards

Richard Blewett - DevelopMentor

http://staff.develop.com/richardb/weblog
nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<2c**************************@posting.google.com >

Try using this to build impersonation into your program and then run
it.

http://www.codeproject.com/csharp/cpimpersonation1.asp

It might help to just use the source code already provided to see if
you can access the regex. That way you dont have to modify your own
code if it doesnt work, which i doubt.

:-)
Sushant

"Dennis C. Drumm" <de*******@primacode.com> wrote in message
news:<#C**************@TK2MSFTNGP09.phx.gbl>...
Can my program access the HKEY_LOCAL_MACHINE/Software section of the
registry when being used by a user with restricted rights (not with
admin
rights)?

If so, how? I have a program that functions just fine when run by an
administrator but generates an exception when run by a restricted user.
The
program accesses the HKEY_LOCAL_MACHINE/Software section to set or get
application settings that are not user specific.

Thanks,

Dennis


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004

[microsoft.public.dotnet.languages.csharp]

Nov 16 '05 #6

P: n/a
Actually looking at the DACL on CommonAppDataRegistry, a user won't be able to write to that. So so should write to teh file system CommonAppDataPath (which maps to documents and settings\all users) whose DACL allows users to write. You should write the CommonAppDataRegistry on application installation for installation option data. Everything else should go in the usr settings prefereable as different users will want different options potentially. To get to previous version settings just go to the registry directly and and read the settings then write them for the new version on installation

Regards

Richard Blewett - DevelopMentor

http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<uN*************@TK2MSFTNGP09.phx.gbl>

Thanks to everyone for the responses.

Richard, since the Application.CommonAppDataRegistry puts information in a
key associated with an application version, is there a way to retrieve
common user data from keys created for previous versions of the application?

Thanks,

Dennis

"Richard Blewett [DevelopMentor]" <ri******@develop.com> wrote in message
news:OO**************@tk2msftngp13.phx.gbl...
You should never store volatile application data in HKEY_LOCAL_MACHINE -
you are guaranteeing that only administrators will be able to use your
program

The appropriate place to put shared data in the registry is exposed via

System.Windows.Forms.Application.CommonAppDataRegi stry

and user data via

System.Windows.Forms.Application.UserAppDataRegist ry

under both of these you should have keys for <companyname>\<product>

this is the standard non-admin required way of storing information in the
registry

For storing files there are equivelent areas of the file system exposed by
the Application class too.

Regards

Richard Blewett - DevelopMentor

http://staff.develop.com/richardb/weblog
nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<2c**************************@posting.google.com >

Try using this to build impersonation into your program and then run
it.

http://www.codeproject.com/csharp/cpimpersonation1.asp

It might help to just use the source code already provided to see if
you can access the regex. That way you dont have to modify your own
code if it doesnt work, which i doubt.

:-)
Sushant

"Dennis C. Drumm" <de*******@primacode.com> wrote in message
news:<#C**************@TK2MSFTNGP09.phx.gbl>...
Can my program access the HKEY_LOCAL_MACHINE/Software section of the
registry when being used by a user with restricted rights (not with
admin
rights)?

If so, how? I have a program that functions just fine when run by an
administrator but generates an exception when run by a restricted user.
The
program accesses the HKEY_LOCAL_MACHINE/Software section to set or get
application settings that are not user specific.

Thanks,

Dennis


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004

[microsoft.public.dotnet.languages.csharp]


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004

[microsoft.public.dotnet.languages.csharp]
Nov 16 '05 #7

P: n/a
Hi Dennis,

I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.