views:

21

answers:

1

I have an ASP.NET application that's trying to copy a file to a remote share that's on a server on another domain ("REMOTEDOMAIN"):

File.Copy(@"c:\Test.txt", @"\\REMOTEMACHINE\Share");

When we get to the File.Copy method, I'm getting "Login failure: Unknown user name or password" when trying to connect to the share through the local IIS install. This is despite the share itself having "Everyone" read/write permissions (temporarily, at least). The Security log on the remote server logs the same error, so I know the process is at least trying to get to the right place.

I sort of understand why, as the website's application pool is attempting to authenticate with an account on LOCALDOMAIN and not REMOTEDOMAIN.

However, the weird thing is, the entire process works fine when I test through the ASP.NET Development Server instead of IIS, despite the fact that both the Development Server and the IIS Application Pool are using the same credentials.

Any thoughts on how to further diagnose this? Unfortunately the test site has to remain on LOCALDOMAIN and the files still have to be copied to REMOTEDOMAIN; I can't move one site to the other or vice versa.

+1  A: 

Everyone does not include Anonymous, so the user still needs to be in the domain of the REMOTEDOMAIN (http://support.microsoft.com/kb/278259). You could get this working by allowing "Guest", but it would be a security nightmare of course so it is not much of a help.

The solution would be to impersonate Asp.Net user: http://support.microsoft.com/kb/306158

One hack that you should know is that if the IIS is not in the remote domain, you can go around this problem, by setting up local (non-domain) users on both machines and setting the same password for both of them.

despite the fact that both the Development Server and the IIS Application Pool are using the same credentials.

Are you absolutely sure about this? If you are talking about the Visual Studio dev server, it runs on your account. And typically Asp.Net runs as "Network Service"

Ope
I'm sure they're running under the same context - I changed the app pool of the site to use my domain account temporarily to test it and still ran into the issue. After the change, the error in the remote server's log actually said "login failure" and listed the specific account. I'm not so much confused as to why this isn't working in IIS; that sort of permissions thing makes sense to my. I don't really understand why it would work with the development server though.
MisterZimbu
I'll try the non-domain user hack out for size. I was thinking of doing that but wanted to avoid it for some reason. Thanks!
MisterZimbu
What are the .Net, IIS and Windows versions?
Ope
Actually forget the previous question. I think regardless of the version, the thing is you need to do the impersonation in the .config (web or machine). Setting the app pool useer does not work because those credentials cannot be passed to remote machine.
Ope
Changing the user on the application pool to a local account worked great. Thanks
MisterZimbu