Impersonating a Windows user

前端 未结 3 2071
自闭症患者
自闭症患者 2020-11-30 07:46

I am using the code to impersonate a user account to get access to a file share.

public class Impersonator :
    IDisposable
{
    #region Public methods.
           


        
3条回答
  •  盖世英雄少女心
    2020-11-30 08:48

    If I'm understanding correctly, your intention is to run the process in the impersonation context.

    The doc from CreateProcess (which is used by Process.Start) says: If the calling process is impersonating another user, the new process uses the token for the calling process, not the impersonation token. To run the new process in the security context of the user represented by the impersonation token, use the CreateProcessAsUser or CreateProcessWithLogonW function.

    So, you're using the wrong API for doing that.

提交回复
热议问题