{"action":"created","issue":{"url":"https://api.github.com/repos/jascam/CodePlexFoo/issues/306","repository_url":"https://api.github.com/repos/jascam/CodePlexFoo","labels_url":"https://api.github.com/repos/jascam/CodePlexFoo/issues/306/labels{/name}","comments_url":"https://api.github.com/repos/jascam/CodePlexFoo/issues/306/comments","events_url":"https://api.github.com/repos/jascam/CodePlexFoo/issues/306/events","html_url":"https://github.com/jascam/CodePlexFoo/issues/306","id":267892642,"number":306,"title":"How do I take ownership of a Registry Key using C#?","user":{"login":"jascam","id":13953383,"avatar_url":"https://avatars0.githubusercontent.com/u/13953383?v=4","gravatar_id":"","url":"https://api.github.com/users/jascam","html_url":"https://github.com/jascam","followers_url":"https://api.github.com/users/jascam/followers","following_url":"https://api.github.com/users/jascam/following{/other_user}","gists_url":"https://api.github.com/users/jascam/gists{/gist_id}","starred_url":"https://api.github.com/users/jascam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jascam/subscriptions","organizations_url":"https://api.github.com/users/jascam/orgs","repos_url":"https://api.github.com/users/jascam/repos","events_url":"https://api.github.com/users/jascam/events{/privacy}","received_events_url":"https://api.github.com/users/jascam/received_events","type":"User","site_admin":false},"labels":[{"id":728829720,"url":"https://api.github.com/repos/jascam/CodePlexFoo/labels/bug","name":"bug","color":"ee0701","default":true},{"id":728831101,"url":"https://api.github.com/repos/jascam/CodePlexFoo/labels/CodePlexMigrationInitiated","name":"CodePlexMigrationInitiated","color":"ededed","default":false},{"id":728839592,"url":"https://api.github.com/repos/jascam/CodePlexFoo/labels/impact:%20Low","name":"impact: Low","color":"ededed","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-10-24T04:20:44Z","updated_at":"2017-10-24T04:21:42Z","closed_at":null,"author_association":"OWNER","body":"have a registry key whose owner is \"Trusted Installer\".\n \n \n \nNow I know I can take ownership of the key manually by using registry editor by doing these steps:\n \n\nRight-click the key - Click Permissions - Click Advanced\n \nClick Owner Tab, Click your user name and check the box \"Replace owner on subcontainers and objects\", Click Apply - Click OK.\n \n\nClick Administrators under Group or user name, check Allow Full Control. Then Click Apply - Click OK.\n \n\n\n \nNow my question is, How can I take ownership of the registry key programmatically?\n \nIf I am able to take ownership of a registry key programmatically, then my problem is solved. Please help.\n \nI've tried doing this:\n \nstring user = Environment.UserDomainName + \"\\\" + Environment.UserName;\nRegistrySecurity rs = new RegistrySecurity();\nrs.AddAccessRule(new RegistryAccessRule(user,\n       RegistryRights.ReadKey | RegistryRights.Delete,\n       InheritanceFlags.None,\n       PropagationFlags.None,\n       AccessControlType.Allow));\n\nrs.AddAccessRule(new RegistryAccessRule(user,\n       RegistryRights.WriteKey | RegistryRights.ChangePermissions,\n       InheritanceFlags.None,\n       PropagationFlags.None,\n       AccessControlType.Allow));\n\n \nRegistryKey RK = Registry.ClassesRoot.OpenSubKey(\"<somekey>\", true);\nRK.SetAccessControl(rs);\n \n \nbut an error message that says that \"Requested registry access is not allowed\" and it occurs on this line:\n \nRegistryKey RK = Registry.ClassesRoot.OpenSubKey(\"<somekey>\", true);<br/>\n \nI am also running Visual Studio as Administrator.\n \n \n \nAgain, If you know how to programmatically take ownership of a registry key, then you have solved my problem.\n \nI understand you can also use these functions: RegOpenKeyEx and RegSetKeySecurity to Take Ownership of a registry key but I don't know how to use them. Can someone give a sample with an explanation on how to use them.\n \nI have seen these sites before:\nhttp://support.microsoft.com/kb/111546/EN-US/ \nand\nhttp://msdn.microsoft.com/en-us/library/ms724897%28VS.85%29.aspx\n \nBut I still don't understand how I can use them in C#.\n \nThanks in advance.\n\r\n\r\n#### Migrated CodePlex Work Item Details\r\nCodePlex Work Item ID: '8744'\r\nVote count: '3'\r\n"},"comment":{"url":"https://api.github.com/repos/jascam/CodePlexFoo/issues/comments/338869147","html_url":"https://github.com/jascam/CodePlexFoo/issues/306#issuecomment-338869147","issue_url":"https://api.github.com/repos/jascam/CodePlexFoo/issues/306","id":338869147,"user":{"login":"jascam","id":13953383,"avatar_url":"https://avatars0.githubusercontent.com/u/13953383?v=4","gravatar_id":"","url":"https://api.github.com/users/jascam","html_url":"https://github.com/jascam","followers_url":"https://api.github.com/users/jascam/followers","following_url":"https://api.github.com/users/jascam/following{/other_user}","gists_url":"https://api.github.com/users/jascam/gists{/gist_id}","starred_url":"https://api.github.com/users/jascam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jascam/subscriptions","organizations_url":"https://api.github.com/users/jascam/orgs","repos_url":"https://api.github.com/users/jascam/repos","events_url":"https://api.github.com/users/jascam/events{/privacy}","received_events_url":"https://api.github.com/users/jascam/received_events","type":"User","site_admin":false},"created_at":"2017-10-24T04:21:42Z","updated_at":"2017-10-24T04:21:42Z","author_association":"OWNER","body":"Hello iCodeRegistry ,\r\n    I am sorry that I don't make clear your content. You sample idea should use SetOwner function to do that and it should invoke NTAccount class which contains in System.Security.Principal namespace. And if you want to get the group's owner, then you should use GetGroup function.\r\nI am sorry again about my careless. Thanks for providing valuable suggestion.\r\n\r\n\r\n\r\nWelcome you continue to support our project.\r\n\r\n\r\n\r\nThanks\r\nAll-In-One Code Framework\r\nhttp://1code.codeplex.com \r\n\r\nThis comment was posted by orichisonic on 5/10/2011\r\n"}}
{"actor":{"display_login":"jascam"}}