mattjohnsonpint/SimpleImpersonation

New Process Is Not Started As Impersonated User

brianushman opened this issue · 1 comments

Hello,

I'm trying to start a instance of FireFox as an impersonated user. However, when I run it and check the Task Manager, I see the process was started as the user logged in to the OS and not the impersonated user. I've tried just about all of the logonTypes but no luck. Could I be misunderstanding what this library does? Thanks for the help!

static private Process StartProcess()
{
    var credentials = new SimpleImpersonation.UserCredentials("MyDomain", "MyUsername", "MyPasswordPlainText");
    SimpleImpersonation.Impersonation.RunAsUser(credentials, SimpleImpersonation.LogonType.Interactive, () => {
        Process proc = new Process();
        proc.StartInfo.FileName = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
        proc.Start();
        return proc;
    });
}

As of version 4.0.0, this library simply exposes a SafeAccessTokenHandle that can be used with WindowsIdentity.RunImpersonated and similar methods. Thus, any further discussion about what works within such impersonated code is better served at https://github.com/dotnet/runtime/issues. Thanks.