I am running an external program from ASP.NET :
var process = new Process(); var startInfo = process.StartInfo; startInfo.FileName = filePath; startInfo.Arguments = arguments; startInfo.UseShellExecute = false; startInfo.RedirectStandardOutput = true;
Everything works fine with this code: the external program is executed and processed .StandardOutput.ReadToEnd () returns the correct output.
But after I add these two lines before process.Start () (to run the program in the context of a different user account):
startInfo.UserName = userName; startInfo.Password = securePassword;
The program is not executed and is being processed. StandardOutput.ReadToEnd () returns an empty string. Exceptions are not thrown.
userName and securePassword are correct (an exception is thrown if the credentials are incorrect).
How to run the program in the context of another user account?
Environment: .NET 4, Windows Server 2008 32bit
UPD:
The application works fine on the ASP.NET + Windows 7 development server, but does not work on IIS 7 + Windows Server 2008 Web Edition.
UPD2:
This is detected in the event log:
Incorrect cryptcp.exe application, version 3.33.0.0, time stamp 0x4be18460, kernel32.dll error module, version 6.0.6002.18005, time stamp 0x49e03821, exception code 0xc0000142, error offset 0x00009eed, process identifier 0xbf4, application start time 0x01caf1b91f5b851a.
cryptcp.exe is the name of the external application.
alexey
source share