Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File access across domains?

Status
Not open for further replies.

Stat792

Programmer
Jan 7, 2004
12
0
0
US
How can I access a file that's on the same physical network but on a differnet domain? Should I just specify the server?

I'll need differnet user credentials to login to that domain also.
 
There are a few approaches... unfortunately using Windows APIs.

1) Have the user create a mapped network drive to the files you need using the correct credentials. This will be outside of the control of your program though.

2) Change the security context of your application to run under the user that has access to the file with the LogonUser API. This requires that your computer is a member of the external domain though. I vaguely remember this being encapsulated in the .net framework somewhere so you might not need to use the Windows API.

3) The approach I ended up using which is the WNetAddConnection API. It is the equivalent of the Net Use command on the command prompt. It provides you with the equivalent functionality of opening a network address like \\computername\sharename and providing a username and password that can include the domain name if necessary just like you would be prompted for by Windows. It does not require making a mapped network drive.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top