I'm trying to lock down a registry key with some important information that must be accessible at the client machine, I do not wan't non-administrators to have access to this key. If you are an admin you'll already be able to do more damage than what I'm storing in the key.
What I'm currently looking to do is this:
//Allow access only to administrators and deny all rights to everyone else.
System.Security.AccessControl.RegistrySecurity acl =
new System.Security.AccessControl.RegistrySecurity();
acl.AddAccessRule(
new System.Security.AccessControl.RegistryAccessRule(
"Administrators",
System.Security.AccessControl.RegistryRights.FullControl,
System.Security.AccessControl.AccessControlType.Allow));
acl.AddAccessRule(
new System.Security.AccessControl.RegistryAccessRule(
"Everyone",
System.Security.AccessControl.RegistryRights.FullControl,
System.Security.AccessControl.AccessControlType.Deny));
//Prevent inherited read access from the software or company key allowing access.
acl.SetAccessRuleProtection(true, false);
MyKey.SetAccessControl(acl);
If I have it right this will deny access to everyone, allow access explicitly to anyone in the administrators group and will prevent all inherited permissions from applying to my key? I'd rather find out if it will work before I screw up the ACL on the key such that I can't delete it etc. Should I set the owner of the key to be the administrators group as well?
PS: It's very important that the key cannot even be read as a non administrator, not just changed.