开发者

ASP.NET access files on another computer shared folder

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, Fil开发者_如何学JAVAeAccess.Write)
Context.Response.TransmitFile("c:\MyProj\file.doc");

Regards, Tomas


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜