OpenSubKey() Requested registry access is not allowed

J

Judith Schmidt

Hi group,

i search a way to change permissions of a registry key, where only the
system account have got full rights.
It is not stupid to think that this is possible because i am the owner
(administrator) of the key and it is possible to change it with
regedit32.exe.

The following code fails on OpenSubKey() with
System.Security.SecurityException: Requested registry access is not allowed

// ----start----
SetPermissions(){
String^ user = Environment::UserDomainName + "\\testuser";
RegistryKey^ openedKey;
RegistrySecurity regSecurity = gcnew RegistrySecurity();
regSecurity->AddAccessRule(gcnew RegistryAccessRule(user,
RegistryRights::ReadKey,
InheritanceFlags::ContainerInherit | InheritanceFlags::ObjectInherit,
PropagationFlags::InheritOnly,
AccessControlType::Allow));
regSecurity->SetAccessRuleProtection(false,true);
openedKey =
Registry::Users->OpenSubKey("S-1-5-18\\software\\testkey",true);
openedKey->SetAccessControl(regSecurity);
return 0;
}
// ----end----
 

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