ASP.NET 访问另一台计算机共享文件夹上的文件

发布于 2024-08-31 12:08:44 字数 331 浏览 0 评论 0原文

我有 ASP.NET 项目,它执行一些文件访问和操作,我用于文件访问的方法如下。现在我需要访问另一台服务器共享文件夹上的文件,该怎么做?我可以轻松地将文件路径更改为共享文件夹路径,但出现“无法访问”错误,因为共享受密码保护。 据我了解,在执行下面的方法之前,我需要以某种方式将凭据发送到远程服务器。怎么做呢?

FileStream("c:\MyProj\file.doc", FileMode.OpenOrCreate, FileAccess.Write)
Context.Response.TransmitFile("c:\MyProj\file.doc");

问候, 托马斯

I have ASP.NET project which do some file access and manipulation, the methods which I use for file access are below. Now I need to access files on another server shared folder, how to do that? I easily can change file path to shared folder path but I get "can't access" error because shares are password protected.
As I understand I need somehow to send credentials to remote server before executing methods below. How to do that?

FileStream("c:\MyProj\file.doc", FileMode.OpenOrCreate, FileAccess.Write)
Context.Response.TransmitFile("c:\MyProj\file.doc");

Regards,
Tomas

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

邮友 2024-09-07 12:08:44

ASP.NET 应用程序(默认情况下)将在 IIS6 中以“ASPNET”计算机帐户执行。因此,您有几个选择:

  • 将 ASPNET 应用程序配置为在具有访问远程计算机共享权限的(弱)域帐户下运行
  • 设置共享上的权限以启用对“所有人”的访问(不推荐)
  • 禁用表单身份验证和在 ASP.NET 应用程序中使用 Windows 身份验证。关闭 web.config 中的模拟,IIS 应该将当前正在使用您的 Web 应用程序的用户的凭据传递到底层共享(我认为)。

当然,后一个选项只有在您的用户都在 Intranet 上拥有域帐户的情况下才有用。我将继续寻找添加凭据的方法,但我不确定这是否可能。

HTH,

理查德。

An ASP.NET application (by default) will execute in IIS6 under the "ASPNET" computer account. You therefore have a couple of options:

  • Configure your ASPNET application to run under a (weak) domain account with permissions to access the remote computer's share
  • Set the permissions on the share to enable access to "Everybody" (not recommended)
  • Disable Forms authentication and use Windows authentication in your ASP.NET app. Turn off impersonation in web.config and IIS should pass the credentials of the user who is currently using your web application through to the underlying share (I think).

The latter option is only useful, of course, if your users all have domain accounts on your intranet, for instance. I'll continue to look around for ways to add credentials but I'm not sure off the top of my head if that's possible.

HTH,

Richard.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文