gpt4 book ai didi

asp.net - 使用本地系统应用程序池标识时,进程仅适用于 Web 应用程序

转载 作者:行者123 更新时间:2023-12-02 16:48:52 24 4
gpt4 key购买 nike

我有一个命令行进程,我正在尝试从 ASP.Net Web 应用程序运行它。

当 IIS7.5 应用程序池标识设置为“本地系统”时,将执行命令行代码。当它设置为 ApplicationPoolIdentity 时,则不会。由于使用“本地系统”存在安全风险,因此我只想向 ApplicationPoolIdentity 授予所需的权限,而不是使用本地系统。

如果我正确理解这个答案:IIS AppPoolIdentity and file system write access permissions ,用户“IIS AppPool[我的应用程序池]”需要被授予对我的命令行进程将要修改的任何文件夹的权限。我已尝试向该用户授予该文件夹的完全权限,但仍然不起作用。我还尝试了 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();
}
}
}

预先感谢您的帮助!!!

最佳答案

事实证明,应用程序池中“高级设置”下的“加载用户配置文件”设置必须设置为 true。通过这样做,PGP 加密程序能够使用该配置文件进行临时数据存储等。

关于asp.net - 使用本地系统应用程序池标识时,进程仅适用于 Web 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16485692/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com