cmd.exe should run in impersonate account.

Discussion in 'ASP .Net Security' started by Arulraj Joseph, Nov 29, 2003.

  1. 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.
    Arulraj Joseph, Nov 29, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    17,827
    mxdev
    Sep 2, 2008
  2. Achim Domma (Procoders)

    read input for cmd.Cmd from file

    Achim Domma (Procoders), Jun 3, 2005, in forum: Python
    Replies:
    2
    Views:
    8,057
    Peter Otten
    Jun 3, 2005
  3. Replies:
    2
    Views:
    346
    Marcus Kwok
    Apr 24, 2006
  4. Bill Belliveau

    DirectoryEntry Impersonate or WindowsIdentity Impersonate?

    Bill Belliveau, Jan 28, 2004, in forum: ASP .Net Security
    Replies:
    3
    Views:
    337
    Joe Kaplan \(MVP - ADSI\)
    Jan 31, 2004
  5. Sol Linderstein
    Replies:
    3
    Views:
    181
    Matt Garrish
    Jun 18, 2004
Loading...

Share This Page