1

I have an asp.net mvc 4 applicatin, that has Process.Start() call to console application (written in c++).

The problem is that the console application doesn't run appropriately from the asp.net application (it generates image from a site, and the image is all white).

When I use the same call from Console Application it works perfectly.

As I see it, it should be privileges problem.

I am not quit sure if the ASP.NET runs from the same user, but I saw here that it runs under my user account (which is admninistrator) so it is really weird.

Things I've tried:

  1. process.StartInfo.UseShellExecute = true/false.

  2. process.StartInfo.UserName and Password of administrator user.

  3. Edit the IIS Configuration file at C:\Users\MyUser\Documents\IISExpress\config\applicationhost.config changing from:

    <applicationPoolDefaults managedRuntimeLoader="v4.0" >
        <processModel/>
    </applicationPoolDefaults>
    

    to:

        <applicationPoolDefaults managedRuntimeLoader="v4.0" >
            <processModel userName="administrator username" password="administrator password"/>
        </applicationPoolDefaults>
    

    so if anonymous requests will execute under the identity of the process, and the process doesn't have the privileges, the explicit user will be used for the anonymous authentication. Taken From Here

Thanks for the help!

Community
  • 1
  • 1
Aviran Cohen
  • 5,581
  • 4
  • 48
  • 75

1 Answers1

0

Check out the section on "Impersonate a Specific User in Code"

http://support.microsoft.com/kb/306158#4

You should be able to make a call to Process.Start from your code after impersonating the specified user and the process will be created using that identity. After the process is started, you should call "impersonationContext.Undo()" to return the user identity back to the App Pool Identity.

If you use another approach to impersonate a user from within ASP.NET, then the whole app will have elevated permissions. It is best to limit those elevated permissions to just this process.

Jeremy Bell
  • 698
  • 5
  • 9