File.Copy error: File not found when remote

G

Guest

Hi,

I have a problem in a peace of code were i'm doing a file copy using
File.Copy. The Source is local and the target is a remote machine.

Example: File.Copy(C:\temp\hi.txt, \\myremote\c$\temp\hi.txt, true);

This API is run from a web service that exposes it. The problem is as follows:

1) I request a page (On the web service machine) from my web server (Note
this page asks what file you need for example).
2) When i click on the submit button the file is copied just fine
3) Now i got to another client machine int he same domain and i log in as
the domain admin ect..
4) I request my client page so i can request a file to be copied.
5) I click ont he submit button and i get an error in my log stating that it
could not find the file specified?

The messed up part is that i have sat at the debugger side by side and
walekd the code on both machines ( one attached to the remote machine and one
attached local) and i get the same information thru the code except when i
get to the File.copy statment, the remote blows up with the file not found
error and the other works just fine. Both of them talk to the same web server
and web service so thisi s something i can't even start to figure out.

Thanks for any help!
 
W

Willy Denoyette [MVP]

POnfri said:
Hi,

I have a problem in a peace of code were i'm doing a file copy using
File.Copy. The Source is local and the target is a remote machine.

Example: File.Copy(C:\temp\hi.txt, \\myremote\c$\temp\hi.txt, true);

This API is run from a web service that exposes it. The problem is as
follows:

1) I request a page (On the web service machine) from my web server (Note
this page asks what file you need for example).
2) When i click on the submit button the file is copied just fine
3) Now i got to another client machine int he same domain and i log in as
the domain admin ect..
4) I request my client page so i can request a file to be copied.
5) I click ont he submit button and i get an error in my log stating that
it
could not find the file specified?

The messed up part is that i have sat at the debugger side by side and
walekd the code on both machines ( one attached to the remote machine and
one
attached local) and i get the same information thru the code except when i
get to the File.copy statment, the remote blows up with the file not found
error and the other works just fine. Both of them talk to the same web
server
and web service so thisi s something i can't even start to figure out.

Thanks for any help!

What you have here is a security issue.
When you run the client on the same machine as the web server, the
webservice uses the client's credentials to authenticate with the remote
file server. However, when you run the client on a separate box from the web
server, these credentials are not available on the webserver (though the
client is authenticated) so the webservice can't make an authenticated
second hop to the resource server using the base client's credentials.
One possibility to solve this is to set-up Kerberos delegation
(Check:
http://www.microsoft.com/msj/0899/kerberos/kerberos.aspx and
http://www.microsoft.com/technet/prodtechnol/windows2000serv/deploy/confeat/kerberos.mspx)
for details.)

Note that this requires a W2K Kerberos realm (Active Directory Domain) to
run.
When you run the Webservice on W2K3 you can take advantage of the Kerberos
extension (Check this article:
http://www.microsoft.com/technet/prodtechnol/windowsserver2003/technologies/security/constdel.mspx).
so you are free to use any protocol available to authenticate the base
client (Basic, SSL, ...) other than Kerberos.

Another option (preferable) is to run the "remote file server access code"
in a server type COM+ application (System.EnterpriseServices namespace)
running with fixed identity having access to both local and remote
resources.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top