File.OpenRead() 访问工作组内共享上的文件而不是远程共享上的文件?
我有一个 ASP.NET MVC 应用程序,它尝试使用文件流和 File.OpenRead() 读取文件。 当文件的路径是同一工作组上的共享,并且我授予该共享的网络服务访问权限时,这可以完美地按预期工作。
但是,当共享路径是 LAN 内远程共享的 UNC 路径时,并且为“Everyone”打开读取权限时,“File.OpenRead()”方法会抛出异常,提示“无法找到该文件的一部分”。小路”。
在我的测试用例中,我正在本地调试 ASP.NET MVC 应用程序,该应用程序被赋予了它实际运行的计算机的 UNC 路径。 它是我的 C 驱动器上的共享,被“共享”,并具有“每个人”的读取访问权限。
IIS中有什么需要配置的吗? 如果我尝试模拟,在这种情况下,模拟并不重要,因为网络服务是在同一工作组中的共享工作时尝试访问文件的用户。
I have an ASP.NET MVC application that attempts to read a file in using a filestream and File.OpenRead().
When the path to the file is a share on the same workgroup, and I give access to NETWORK SERVICE for the share, this works perfectly as desired.
However, when the path to the share is a UNC path to a remote share within the LAN, with read permissions open for "Everyone", the "File.OpenRead()" method throws an exception saying "Could not find a part of the path".
In my test cases I'm debugging locally with the ASP.NET MVC app being given a UNC path to the computer that it's actually running on.
It's a share on my C drive, being "Shared" with permissions to "Everyone" for read access.
Is there something in IIS that needs to be configured?
If I try to impersonate, in this context, the impersonation doesn't matter because NETWORK SERVICE was the user trying to access the files when it worked for a share in the same workgroup.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
IIS 在以不同的方式访问远程共享时处理身份验证。请查看这篇文章:IIS 6.0 中的 UNC 身份验证。或者搜索
IIS UNC site:microsoft.com
IIS handles authentication when accessing remote shares in a distinct way. Please take a look at this article: UNC Authentication in IIS 6.0. Or search for
IIS UNC site:microsoft.com
验证共享权限以确保授予 NETWORK SERVICE 帐户能够访问共享的权限。共享以及实际文件/文件夹都需要权限。
[]的
Verify the share permissions to make sure that the permissions are given to NETWORK SERVICE account to be able to access the share. Permissions are needed to the share as well as the actual files/folders.
[]'s