My application should impersonate the service account that I am running with my own LogonUser call. However, it seems that random components in the .Net library are trying to access registry keys that the account does not have access to, resulting in a SecurityException .
In particular, when I load LinkLabel , it crashes trying to determine the default hyperlink color in IE:
System.Security.SecurityException: Requested registry access is not allowed.
at System.ThrowHelper.ThrowSecurityException (ExceptionResource resource)
at Microsoft.Win32.RegistryKey.OpenSubKey (String name, Boolean writable)
at Microsoft.Win32.RegistryKey.OpenSubKey (String name)
at System.Windows.Forms.LinkUtilities.GetIEColor (String name)
at System.Windows.Forms.LinkUtilities.get_IELinkColor ()
at System.Windows.Forms.LinkLabel.get_LinkColor ()
at System.Windows.Forms.LinkLabel.OnPaint (PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling (PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint (Message & m)
at System.Windows.Forms.Control.WndProc (Message & m)
at System.Windows.Forms.Label.WndProc (Message & m)
at System.Windows.Forms.LinkLabel.WndProc (Message & msg)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage (Message & m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc (Message & m)
at System.Windows.Forms.NativeWindow.Callback (IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
The Zone of the assembly that failed was: MyComputer
No, the default color setting does not help.
I found this thread with the same problem, but I'm afraid I don't understand the solution:
The registry utilities downloaded using LoadUserProfile are stored in HKU, HKCU remains the hive of the user of the interactive login (the winlogon.exe is loaded).
So, if you need to get into a recently loaded bush, you need:
- install Regkey in Registry.Users
- Open the subsection using the SID string of the user account that you are issuing.
Does anyone know of any workarounds for this?
source share