我正在尝试锁定一个包含重要信息的注册表键,这些信息必须在客户端机器上被访问,我不希望非管理员能够访问此键。如果你是管理员,你已经可以造成比我存储在键中更多的损坏。
我目前想做的是:
//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);
如果我理解正确,这将拒绝所有人的访问,明确允许管理员组中的任何人访问,并防止所有继承的权限应用于我的密钥?在我搞砸密钥ACL以至于我无法删除它之前,我更想知道它是否有效。我是否应该将密钥的所有者也设置为管理员组?
PS:非管理员甚至不能读取密钥,而不仅仅是更改。