IIS无法访问文件,但用户可以通过同一帐户登录

时间:2011-01-31 14:55:58

标签: windows iis-7 permissions

我们最近将一个Web应用程序移到了一台新机器上。旧的是Win2k,IIS 6。

新机器是Win Server 2003,IIS 7。

该应用程序之前在网络共享上查找图像文件,映射为驱动器号O。这很好。

移动后,应用程序无法再访问这些文件。尝试访问O:驱动器文件的应用程序部分是一个已编译的CGI,所以我不确定它内部是什么样的。我可能可以访问源代码,但我决定尝试一个非常简单的测试,试着先看看出了什么问题。

为了尝试排除故障,我创建了一个小型C#程序,尝试在本地访问测试文件(在C:驱动器上),然后在O:驱动器上查找文件,然后{ {1}}驱动器,然后查找与Z:驱动器上相同的文件,但使用UNC路径而不是依赖于驱动器映射。最后,它打印出运行的域和用户名。我通过用于注册从旧服务器移出的原始EXE的相同方法将其注册为CGI。

O:驱动器上的文件读取没有问题,但无法读取其他文件。 C#应用告诉我,它在C:域下以Washington$帐号运行。我正在使用的帐户是Traffic(请注意,最后一个帐户有Washington,其中一个帐户没有)。

在我尝试并获得失败后,我通过远程桌面以$域上的用户:Washington登录,并且能够在UNC路径上看到测试文件问题(在命令提示符下通过Traffic进行测试。

我没有绑定映射的驱动器号;实际上我想切换到使用UNC路径。

另外,我对Windows域和IIS管理/管理都很陌生。这个问题可能有一个非常基本的根本原因,我只是不知道或忽视。

我的程序输出如下:


--- Success opening C drive file! ---
Failed to open O drive file:

System.IO.DirectoryNotFoundException: Could not find a part of the path 'O:\testFile.txt'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at System.IO.File.OpenRead(String path)
   at Testing.Main()

Failed to open Z drive file:

System.IO.DirectoryNotFoundException: Could not find a part of the path 'Z:\testFile.txt'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at System.IO.File.OpenRead(String path)
   at Testing.Main()

Failed to open UNC file:

System.UnauthorizedAccessException: Access to the path '\\trsystem\images2\testFile.txt' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at System.IO.File.OpenRead(String path)
   at Testing.Main()
---------- ---------- ----------
Domain Name is:TRAFFIC
UserName is:WASHINGTON$

而且,程序本身(请注意,这是我第一次尝试进入C#;并根据网络示例将它们拼凑在一起所以请忽略它的丑陋):

dir \\trsystem\images2\testFile.txt

提前感谢任何帮助或疑难解答的想法!

1 个答案:

答案 0 :(得分:0)

为什么不在Microsoft KB上花些时间?

http://support.microsoft.com/kb/257174

IIS不支持映射驱动器,因此您看到的只是设计。