views:

176

answers:

1

I have an ASP.NET MVC web app and in one of the controller actions I want to start process (exe file). The process needs to run under a domain user, because it accesses other resources on the domain. This can either be a single hard coded user, or the user that is currently on the web page. The web.config is using Windows authentication.

I have tried turning impersonation on and tried turning impersonation on specifying a specific user. Both of these scenarios will cause permission issues.

I have also tried starting the process as a specific domain/user/password, but this will give me an error "Logon failure: unknown user name or bad password". I'm positive that the username/password is correct, and doing a "runas" works fine.

I'm not even sure of the "correct" way to do this. Any help is appreciated.

Thanks.

+1  A: 

The correct way is to not launch a process from a Web app. Use something like MSMQ in WCF instead.

RichardOD
Ok, so shove some info into MSMQ, then pull it out with a service that is running as a user that can handle this... I could just create a WCF service to do the work that the exe is currently doing then. I was hoping to not have to have a whole other service to do this. Maybe that's the best way though.
Josh Close
It shouldn't be too difficult to do. If you have Windows server 2008 you could host the service using WAS- http://msdn.microsoft.com/en-us/library/ms734677.aspx. Writing a Windows service isn't really that much more work though- it took me less than 10 minutes to convert a console WCF service into a Windows Service (I only have Windows 2003).
RichardOD
I'm going to move my exe code into a WCF service that's started as a domain user and see if that works better.
Josh Close
Doing it as a WCF service hosted in a Windows service worked great. I just set the Windows service startup user as the domain account.
Josh Close
Josh- that's good. Glad it worked for you!
RichardOD