Good Day,
My web app is set to use Windows Authentication and Impersontation is set to true.
I wan’t to launch a process using the logged-in user account. However, when I tried to launch notepad.exe, it was run as a NETWORK SERVICE.
I’ve tried different impersonation techniques, but none of them worked.
Please help.
Simple impersonation won’t allow you to start a process as another user. You would have to use
CreateProcessAsUserfrom the Windows API together with the appropriate privilegesThe
CreateProcessAsUserfunction does not need the password of a user. It requires a primary token which can be obtained from theSystem.Security.Principal.WindowsIdentityobject. Your ASP.NET process must have the Act as part of the operating system privilege to get an impersonation-level token.How To: Use Impersonation and Delegation in ASP.NET 2.0 has all the details on this topic.
A related question which also might be relevant is this one: Using Process.Start() to start a process as a different user from within a Windows Service.