Starting a new Process under a Specified Windows Account

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

One of our ASP.NET Pages is starting a new Process using the Process object.
When the process starts, it is started under the ASPNET User. We tried
editing the web.config file and the machine.config to operate under other
user accounts but our dynamically started process still starts under ASPNET.
How do you programatically start a process under a specific Windows User
Account? Thanks so much!

Christopher
 
Hi Christopher:

Did you change the processModel in web.config and verify the worker process
launches under the newly specified account? Any process spawned will inherit
the identity of the parent process with the Process class in .NET 1.x.

Outside of this approach, you'll need to PInvoke CreateProcessAsUser, CreateProcessWithLogonW,
or CreateProcessWithTokenW. It's easier and more secure to use the above
method, however.
 
Unfortunately, impersonation doesn't help when creating a new process.

A new process always inherits the security context of the parent process,
even if the thread starting the child process is impersonating. The only
way to create a child process under a different account (in 1.x) is to PInvoke
one of the CreateProcessWith* APIs.

In 2.0 you can add credentials to the Process class (but this assumes you'll
have the user's password - ugh).
 
Back
Top