A
Arulraj Joseph
Hi All,
I am starting a new process from asp.net(cmd.exe). See the following
code,
System.Security.Principal.WindowsImpersonationContext
impersonationContext =
((System.Security.Principal.WindowsIdentity)User.Identity).Impersonate();
ProcessStartInfo oProcessStartInfo = new ProcessStartInfo();
oProcessStartInfo.FileName = "c:\getUser.exe > c:\a.out";
oProcessStartInfo.Arguments = szCommand;
oProcessStartInfo.RedirectStandardOutput = true;
oProcessStartInfo.CreateNoWindow = false;
oProcessStartInfo.UseShellExecute = false;
Process oProcess = new Process();
oProcess.StartInfo = oProcessStartInfo;
oProcess.Start();
oProcess.WaitForExit();
impersonationContext.Undo();
When the process starts, it is running in the aspnet account and not
the impersonate account. How will I run in the impersonate
account(similar
to launching user concept to dcomcnfg.exe).
Note : getuser.exe will output a user name to c:\a.out the code for
getuser.exe is
using System;
namespace getuser
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Console.WriteLine(System.Security.Principal.WindowsIdentity.GetCurrent().Name);
}
}
}
Help appreciated.
Thanks,
Arulraj Joseph.
I am starting a new process from asp.net(cmd.exe). See the following
code,
System.Security.Principal.WindowsImpersonationContext
impersonationContext =
((System.Security.Principal.WindowsIdentity)User.Identity).Impersonate();
ProcessStartInfo oProcessStartInfo = new ProcessStartInfo();
oProcessStartInfo.FileName = "c:\getUser.exe > c:\a.out";
oProcessStartInfo.Arguments = szCommand;
oProcessStartInfo.RedirectStandardOutput = true;
oProcessStartInfo.CreateNoWindow = false;
oProcessStartInfo.UseShellExecute = false;
Process oProcess = new Process();
oProcess.StartInfo = oProcessStartInfo;
oProcess.Start();
oProcess.WaitForExit();
impersonationContext.Undo();
When the process starts, it is running in the aspnet account and not
the impersonate account. How will I run in the impersonate
account(similar
to launching user concept to dcomcnfg.exe).
Note : getuser.exe will output a user name to c:\a.out the code for
getuser.exe is
using System;
namespace getuser
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Console.WriteLine(System.Security.Principal.WindowsIdentity.GetCurrent().Name);
}
}
}
Help appreciated.
Thanks,
Arulraj Joseph.