Impersonation and CurrentUser Registry Access

前端 未结 2 1829
孤城傲影
孤城傲影 2020-12-16 16:23

Environment: Windows XP SP3, C#, .Net 4.0

Problem:

I\'m attempting to add access to an impersonated users registry hive in an impersonation class and I\'m ru

相关标签:
2条回答
  • 2020-12-16 17:15

    From the LoadUserProfile docs:

    Starting with Windows XP Service Pack 2 (SP2) and Windows Server 2003, the caller must be an administrator or the LocalSystem account. It is not sufficient for the caller to merely impersonate the administrator or LocalSystem account.

    If your process starts as a regular user you're out of luck. You could possibly launch a new process (under the admin credentials) to load the profile.

    0 讨论(0)
  • 2020-12-16 17:16

    I found that the logon type set in the call to LogonUser() can be a factor. Even when running as an administrator I couldn't get past the error unless I switched from LOGON32_LOGON_INTERACTIVE to LOGON32_LOGON_BATCH. You would need to be sure the "Log on as a batch job" group policy doesn't interfere though.

    0 讨论(0)
提交回复
热议问题