views:

1207

answers:

3

Let's say that I have a site where once the user selects a few options, the following (should) happen:

  • Grabs files (in a directory) off of the local machine - works fine so far
  • Moves them to a remote server - this is where I need help

Details:

  • The remote server will be found via UNC path (\servername\xyz)
  • I have access to the username/password to access that UNC path, but since we are on a different domain and I don't control IT's decisions, I can't have a single user that has permissions in both domains.

How do I go about setting up my site to do this? If I impersonate, then I might lose permissions to grab files on the local machine...

Note: I also have FTP access to the remote server. If there is a good FTP API that I could use, that would work as well, but I don't want to have to iterate over each and every file.

Oh, this is .NET 1.1 as well.

+2  A: 

I have done this cross domain before. All you need is for the username and password to be the same and this will work, even if they are in different domains. The thing to make sure of is that your .NET application is running as this user.

For instance:

  • In domain XYZ have a user "filesynch" with a password "pass"
  • In domain PDQ have a user "filesynch" with a password "pass"
  • Make sure user PDQ\filesynch has access to share on machine in PDQ domain
  • Run application on a machine in the XYZ domain as the XYZ\filesynch user
  • Copy files over network
Ray Jezek
+1  A: 

This could be done either with the unc or ftp. For the earlier (unc) you could use File.Copy(source, target) - for the latter you can use a couple of techniques. If you store what the user wanted from the machine on the remote site you could use a webclient (System.Net.WebClient) to download the files via any accessible url (ie: turn file browsing on in IIS).

If you can use .NET 2.0 you have better options with more reliable objects (ie: FtpRequest) - is there a reson why you cant use .NET 2.0?

schmoopy