5

I have a web application, hosted on Windows Server 2008 R2 IIS 7.5 that needs to access a remote directory fileshare on a different Windows machine. My website runs under User1, and access to the remote file share via UNC path requires username/password credentials of User2.

While trying to find the best way to do this, I've run into various options, but I don't really understand the gotchas.

One of our concerns is performance - we don't want to be opening/closing nor authenticating for each and every request. Many of the solutions I've seen so far dispose of the connection after each operation. I think what I'm really looking for is a form of persistent mapped network drive.

So what's the difference between all these options? Can anyone please provide what is the best practice, and sample code if not already in one of the posts below?

  1. using WAddNetworkConnection2
  2. using WAddNetworkConnection3
  3. using WNetUseConnection
  4. using NetUseAdd
  5. launching a command shell and calling "net use"
  6. impersonation?
  7. persistent mapped network drive? but who will create this?
  8. IIS Virtual Directory support?

Some relevant posts:

Accessing a Shared File (UNC) From a Remote, Non-Trusted Domain With Credentials

Connect to network drive with user name and password

How to provide user name and password when connecting to a network share

http://forums.asp.net/t/1915751.aspx?C+Access+Network+Drive+Without+mapping+with+credentials

THANK YOU!

Community
  • 1
  • 1
Raymond
  • 3,382
  • 5
  • 43
  • 67

0 Answers0