Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I want to know ways to start a process using another user without having the password.
The user is authenticated via Windows authentication in asp.net and I get the Identity from him to create WindowsImpersonationContext. I need the Identity to create a certificate, doing this with a process.

C#
WindowsIdentity wi = getIdentity();
WindowsImpersonationContext wic = wi.Impersonate();
System.Diagnostics.Process proc1 = new System.Diagnostics.Process();
try
  {
   proc1.StartInfo.WorkingDirectory = pathDir;
   proc1.StartInfo.FileName = pathexe; 
   proc1.StartInfo.UseShellExecute = false;
   proc1.StartInfo.Arguments = argumentsreq;
   proc1.Start();
   proc1.WaitForExit();
                   
   proc1.StartInfo.Arguments = argumentscert;
   proc1.Start();
   proc1.WaitForExit();
   }
   catch
   {
   }
   finally
   {
   }
   
wic.Undo();

I thougth the new process is run by the impersonated user, but it is not so.
Now I have the problem so start the process with the impersonated user, because I don´t have the password.
I have read something about tokens I could create with the identity, but is that the easiest way to run the process? Is there a better way? If not, how can I run the process with a token?
Posted
Updated 11-Oct-11 0:29am
v2

1 solution

You can't.

Processes are run by the security context of who started it. If you want to run as a different user you have to have the passwords of that user.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900