Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2007

Tip: Looking for answers? Try searching our database.

How could i change permission on registrykey

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Judith Schmidt - 20 Oct 2007 04:56 GMT
Hi

i need a way to set permission on a registry key where i have got not rights
to open it. But i am the owner (administrator).

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----
Willy Denoyette [MVP] - 20 Oct 2007 09:21 GMT
> Hi
>
[quoted text clipped - 22 lines]
> }
> // ----end----

That means you don't run as "administrator". Be aware that "administrators"
run as normal users on Vista! If you need to perform administrative tasks
you'll have to run with elevated privileges.

Willy.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.