Can I set permissions on a registy key in .NET?

  • Thread starter Thread starter Mike Schilling
  • Start date Start date
M

Mike Schilling

What I really want to do is communicate among a number of web services, all
running on the same machine (not necessarily in the same IIS instance) using
the value of a registry entry. I'm have trouble with ASP.NET not having
permission to read and/or write the value. Is there a way for the creator
of the key, which is not a web service, to grant read/write permission to a
set of users, using .NET code?
 
Can you tell if the problem is due to insufficient permissions under OS
security and/or CAS? If you're not sure, might you be able to provide the
full details of the exception (as returned from its ToString method) thrown
when you attempt to read from the key from one of your web services?
 
I am sure; the same code works when run from the command line (as me), or
from ASP.NET if I manually adjust the permission on the key with Regedit.
 
Unfortunately, v. 1.x of the .NET Framework does not include functionality
for directly setting registry ACLs. If you would prefer not to involve any
additional dependencies, your best bet might be to use p/invoke to call the
underlying Windows API functions for setting the relevant ACLs (usually
RegCreateKeyEx and/or RegSetKeySecurity). There is a managed wrapper
library available at
http://www.gotdotnet.com/Community/...mpleGuid=e6098575-dda0-48b8-9abf-e0705af065d9
that might be helpful if you would like to avoid writing the p/invoke code
yourself.
 

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

Back
Top