2

我有一个 MVC Web 应用程序,它使用模板 .xlt 和 .rpt 生成 Excel 和 PDF 报告(使用 Crystal),当我将模板放在 Web 服务器本身时,它生成报告没有故障,但是一旦我将模板放在远程位置,然后我收到一个拒绝访问错误,我通过进程监视器发现了该错误,屏幕截图如下

在此处输入图像描述

当我从服务器通过资源管理器手动浏览远程文件夹时,一切正常,我可以打开我需要的文件,它只是在服务器读取文件时触发访问被拒绝错误。我的 Web 应用程序使用集成管道中的 ApplicationPoolIdentity。身份验证是通过模拟和 Windows 身份验证进行的。甚至令人困惑的是,运行 Excel 模板的用户是我自己,但我的访问被拒绝,而用于生成 PDF 的用户是 IIS Apppool。

有谁知道如何解决访问被拒绝的问题,我已经尝试让所有用户完全访问该文件夹,但它仍然不起作用。

附加信息

我使用的是 IIS 7.5,我还检查了共享所在的文件服务器,在事件日志上注册的用户不是我,而是以下详细信息

An account was successfully logged on.

Subject:
    Security ID:        NULL SID
    Account Name:       -
    Account Domain:     -
    Logon ID:       0x0

Logon Type:         3

New Logon:
    Security ID:        ANONYMOUS LOGON
    Account Name:       ANONYMOUS LOGON
    Account Domain:     NT AUTHORITY
    Logon ID:       0x90eb7c7
    Logon GUID:     {00000000-0000-0000-0000-000000000000}

Process Information:
    Process ID:     0x0
    Process Name:       -

Network Information:
    Workstation Name:   MYWEBSERVER
    Source Network Address: 10.10.10.01
    Source Port:        00000

Detailed Authentication Information:
    Logon Process:      NtLmSsp 
    Authentication Package: NTLM
    Transited Services: -
    Package Name (NTLM only):   NTLM V1
    Key Length:     128

更新

在这种情况下我需要使用ApplicationPoolIdentity,所以我正在寻找一个仍然可以使用ApplicationPoolIdentity 的解决方案。

另一个更新

我在下面尝试了@Davids 的建议,现在我收到了相同的错误消息

System.Runtime.InteropServices.COMException (0x800A03EC):Microsoft Excel 无法访问文件“\MyServer\Templates\MyTemplate.xlt”。有几个可能的原因:

• 文件名或路径不存在。• 该文件正被另一个程序使用。• 您尝试保存的工作簿与当前打开的工作簿同名。在 Microsoft.Office.Interop.Excel.Workbooks.Open(字符串文件名、对象 UpdateLinks、对象只读、对象格式、对象密码、对象 WriteResPassword、对象 IgnoreReadOnlyRecommended、对象来源、对象分隔符、对象可编辑、对象通知、对象转换器、对象Ci.Infrastructure.Reporting.ReportProviderExcel.RunReport() 处的 AddToMru、对象本地、对象 CorruptLoad)

4

1 回答 1

2

I believe your problem is because the application pool needs to be configured to run either as a domain account or network service account.

If you choose the latter you'll need to grant permissions to '<domainname>\<machinename>$' if you choose to run as a specific account then this is the user you will need to grant permissions to.

You've already granted everyone access, so it should just be a case of changing the app pool user, but once you have it working I recommend you restrict this to the specific account.

The following link will give you more information:

http://www.iis.net/learn/manage/configuring-security/application-pool-identities

于 2012-12-18T22:11:23.960 回答