【发布时间】:2017-06-20 11:22:23
【问题描述】:
我在服务器上有一个包含 pdf 文件的文件夹(Windows Server 2008 R2 Enterprise)。我必须使用授权用户帐户打开文件夹并在浏览器中显示 pdf 文件。该用户拥有文件夹的完全控制权限,并且是管理员组的成员。
波纹管代码在我的本地工作,因为它从位于 Adobe Reader 的服务器中的文件夹中打开 pdf 文件。但是在服务器上该进程没有启动(Adobe Reader 没有打开)并且没有发生异常。大多数论坛都说关闭 UAC 会有所帮助,但出于安全原因,我不想这样做。
我该如何处理这个问题?请帮忙。
try
{
WindowsIdentity wi = new WindowsIdentity(@"user_name@DOMAIN");
WindowsImpersonationContext ctx = null;
try
{
ctx = wi.Impersonate();
// Thread is now impersonating you can call the backend operations here...
Process p = new Process();
p.StartInfo = new ProcessStartInfo()
{
CreateNoWindow = true,
Verb = "open",
FileName = ConfigurationManager.AppSettings["mobil"] + "\\" + prmSicilNo + "_" + prmPeriod.ToString("yyyyMM") + ".pdf",
};
p.Start();
}
catch (Exception ex)
{
msj = ex.Message;
}
finally
{
ctx.Undo();
}
return msj;
}
catch (Exception ex)
{
return msj + "Error: " + ex.Message;
}
【问题讨论】:
标签: c# pdf process impersonation process.start