Accessing fileshare using system.IO

G

Guest

I have a machine in a domain 'HOME' and a machine in a DMZ which is not able
to communicate with the 'HOME' domain, and thus has it's own local users and
groups.

I'm writing a .NET assembly which will copy files from the machine in the
domain to the machine in the DMZ. When mapping a drive in Explorer I use the
credentials of the DMZ machine: NLIIS405\copyuser, password: copyuser. This
proves that the connection is available.

The problem is the file.copy in the assembly. I always get an access denied
because I should copy the file using the DMZ machine credentials.

Is there a way to copy files from the domain machine to the DMZ machine
using a DMZ machine login? I suspect it has to do with impersonation, but
don't know if the above is possible.

Does someone has experience with connecting to a network share from a server
which is not connected to a domain?
 
L

Laura T

It is possible. You could also grant permissions for an user of your domain.
Otherwise you could do a WNetAddConnection2/3 to "logon" on the DMZ machine
(in effect you simulate a net use), copy the file and then delete the
connection.

WNetAddConnection3(Form1.Handle,MapDriveStruct,"copyuser","NLIIS405\copyuser",CONNECT_INTERACTIVE);
File.Copy(...)
WNetCancelConnection2(...)

Docs for WNetXXX APIs are here:

http://msdn.microsoft.com/library/d...us/wnet/wnet/windows_networking_functions.asp
 

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