我有一个命令行我试图从ASP.Net Web应用程序运行的进程。当使用本地系统应用程序池标识时,进程只能从Web应用程序运行
当IIS7.5应用程序池标识设置为“本地系统”时,命令行代码将执行。当它被设置为ApplicationPoolIdentity时,它不会。由于使用“本地系统”存在安全风险,因此我只想将所需权限授予ApplicationPoolIdentity,而不是使用本地系统。
如果我没有理解这个答案corretly:IIS AppPoolIdentity and file system write access permissions,网友“IIS应用程序池[我的应用程序池]”需要被赋予的权限,我的命令行程序将被修改的任何文件夹。我试图给该用户的完整权限,但它仍然不起作用。我也尝试了对IUSR和IIS_USRS的完整权限。请看我的代码如下:
using (Process process = new Process())
{
process.StartInfo.FileName = fileToExecute;
process.StartInfo.Arguments = arguments;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
StringBuilder output = new StringBuilder();
StringBuilder error = new StringBuilder();
using (AutoResetEvent outputWaitHandle = new AutoResetEvent(false))
using (AutoResetEvent errorWaitHandle = new AutoResetEvent(false))
{
process.OutputDataReceived += (sender, e) =>
{
if (e.Data == null)
{
outputWaitHandle.Set();
}
else
{
output.AppendLine(e.Data);
}
};
process.ErrorDataReceived += (sender, e) =>
{
if (e.Data == null)
{
errorWaitHandle.Set();
}
else
{
error.AppendLine(e.Data);
}
};
process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
int timeout = 1000;
if (process.WaitForExit(timeout) &&
outputWaitHandle.WaitOne(timeout) &&
errorWaitHandle.WaitOne(timeout))
{
Logs logs = new Logs("Finished! - Output: " + output.ToString() + " | Error: " + error.ToString());
logs.WriteLog();
}
else
{
// Timed out.
Logs logs = new Logs("Timed Out! - Output: " + output.ToString() + " | Error: " + error.ToString());
logs.WriteLog();
}
}
}
在此先感谢您的帮助!
我试过给IIS_IUSRS和IUSR的完整权限,但仍然有同样的问题。用这些信息更新我的问题。 – jpsnow72 2013-05-15 12:28:56
事件日志中报告了哪些错误? – 2013-05-16 10:31:42
我在事件日志中看不到任何错误。 – jpsnow72 2013-05-16 10:53:49