In order to install a new property page into the Active Directory SnapIn, I need to write into the following registry key of W2K8 R2 (as documented by Microsoft)
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MMC\SnapIns{E355E538-1C2E-11D0-8C37-00C04FD8FE93}\NodeTypes
This key is own by a special user called TrustedInstaller. I found a lots of thing on the NET arround that.
At the moment here is the way it works doing the following (user is member of administrator group):
My project is full written in C# and there are two things that I don't like in the way I'am doing it.
So my question is : Do I miss something, is there a documented way to modify such a key which is documented as modifiable ?
There is a Stack overflow question existing about that, the answer say that TrustedInstaller ownership, means the key is part of system installation and not application installation. For me if Microsoft documents how to modify a key it's application installation.
Thanks in advance.
So I found one of my problem.
When you want to take ownership on a resource you add to enable the SeTakeOwnershipPrivilege this allow you to change the owner SID. But the new Owner Sid must be in the caller’s token, plus, that Sid must have attribute SE_GROUP_OWNER. So in my case I was not able to change back SID owner to S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464 (TrustedInstaller). I was just able to take ownership, or to give ownership to the group "Administrators". I discover that there is a king of work-around whereby you can assign any arbitrary user as the owner, even if its SID is not in the token. SeRestorePrivilege privilege that is granted to administrators and backup operators, but NOT enabled by default. Enbling it allow me to give back ownership to TrustedInstaller.
So it works doing the following (user is member of administrator group):
I use InteropServices to call Win32 AdjustTokenPrivileges API, and it seems to be the only way to do it in C#
I will soon post on my blog a small tool that allow to give back ownership to TrustedInstaller.
Edited : Sorry for the delay I just forget it, you can find the code on Gist.