从 IIS AppPool 运行 LibreOffice soffice.exe 创建临时文件的权限问题

问题描述 投票:0回答:1

我正在使用 AppPool 标识从 IIS 站点运行 soffice.exe,以将 docx 转换为 pdf。

不知何故,它尝试在 C:/Windows/LibreOffice 中创建文件,这会导致访问错误。 什么可能导致这种行为?

这是代码部分:

string libreOfficePath = @"C:\Program Files\LibreOffice\program\soffice.exe";
string docxPath = @"D:\docs\abc.docx";
string pdfOutputPath = @"D:\docs\out";
string logPath = @"D:\docs\logs";

string arguments = "--headless --convert-to pdf " + docxPath + " --outdir " + pdfOutputPath;

var startInfo = new ProcessStartInfo
{
    FileName = libreOfficePath,
    Arguments = arguments,
    RedirectStandardOutput = true,
    RedirectStandardError = true,
    UseShellExecute = false,
    CreateNoWindow = true,
    WorkingDirectory = @"C:\Program Files\LibreOffice\program"
};

这些是我的设置: 我已授予应用程序池这些文件夹的权限。

如果我将应用程序池标识设置为 localsystem,该命令将完成工作并创建 pdf。

如果我设置为应用程序池身份,该进程会尝试在 C:/Windows/LibreOffice 中创建临时文件,这显然会失败。

应用程序监视器记录以下内容:

这是它得到的命令行:

"C:\Program Files\LibreOffice\program\soffice.exe" "--headless" "--convert-to" "pdf" "D:\docs\abc.docx" "--outdir" "D:\docs\out" "-env:OOO_CWD=2C:\\Program Files\\LibreOffice\\program"
iis libreoffice
1个回答
0
投票

经过数百次尝试后,使用以下命令指定文件夹:

-env:UserInstallation=

解决了问题。

© www.soinside.com 2019 - 2024. All rights reserved.