cmd.exe should run in impersonate account.

From: Arulraj Joseph (arulraj_joseph_at_yahoo.com)
Date: 11/29/03

  • Next message: Steve: "Error accessing Registry from Windows app"
    Date: 29 Nov 2003 06:11:50 -0800
    
    

    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.


  • Next message: Steve: "Error accessing Registry from Windows app"

    Relevant Pages

    • DirectoryEntry Help
      ... specified domain either does not exist or could not be contacted. ... of ASPNET account, which does not have access to the Active Directory. ... is correct becasue I have used it as a test elsewhere to Impersonate ...
      (microsoft.public.dotnet.framework.aspnet.security)
    • Re: C#.NET reading remote host directory contents
      ... rights to access the folder. ... By defaul web application runs under ASPNET account. ... Impersonate your web application with valid NT credentials in the ...
      (microsoft.public.dotnet.languages.csharp)
    • Re: ASPNET permissions
      ... I dont want the aspnet account to be able to run as admin. ... > the best thing to do would be to impersonate to the admin account. ...
      (microsoft.public.dotnet.framework.aspnet)
    • Re: ASPNET permissions
      ... I dont want the aspnet account to be able to run as admin. ... > the best thing to do would be to impersonate to the admin account. ...
      (microsoft.public.dotnet.framework.aspnet)