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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP File access across Domains

Status
Not open for further replies.

DomPedro

Programmer
Jun 29, 2001
25
GB
I have an issue using a very simple piece of ASP code below. The code takes a path, creates a file system object and then displays the filenames of files in the folder provided.

Firstly, here's the code (it is part of a more complicated application, but this is just a test page for it) :

strAttachDir = "\\fileserver\myfiles"
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(strAttachDir)
Set files = folder.Files

For Each file in files
Response.Write &quot;<p>&quot; & file.name & &quot;</p>&quot;
Next

The fileserver and webserver are in the same domain (say MasterDomain), while I'm logged on using a user who exists in a different domain called OtherDomain (IIS is using Integrated Windows Authentication). If I run an IE browser on the webserver machine while logged in as the user from OtherDomain the list of files is displayed with no problem. However, if I run the browser on any other machine than the web server it returns error 76 Path not found. The asp code works fine only if it is run from a browser on the web server, even if that web server is not in MasterDomain.

Anyone any ideas on why I can't get the list of files if the browser is not being run on the web server? My initial thought was that I wouldn't have been able to do it because of the &quot;cross domains&quot; file access, so I don't understand the symptoms I'm getting.
 
strAttachDir = server.mappath(&quot;\\fileserver\myfiles&quot;)

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
Hmm, looked hopeful initially, but server.mappath won't work with the machine name, as it errors :
Invalid Path Character(s)~An invalid '/' or '\' was found in the Path parameter for the MapPath method.

I've also tried creating a new virtual directory on IIS that points directly to \\fileserver\myfiles, called that /thefiles and then tried using server.mappath with that. Unfortunately, again it works only on a browser running on the web server machine itself, though using comes back with the correct list when run from anywhere on the network.

Is there a flaw in fso.GetFolder that won't work in this scenario?
 
Its only a suggestion ( and not a nice one ), but can you test the page on another machine on the MASTER domain and see if that works?

I'm just wondering if its got something to do with cross domain security.

Mark
 
an option i've used when coming into conflicts with remote files is to map a drive, then you can verify the security and the connection etc, between the two machines via code and standard windows usage, and if there's permission or access or domain issues, they will show up when you try to go there, outside of network neighborhood.
 
Server.MapPath doesn't like physical paths and appears to only support virtual paths, so the Virtual Directory option or using the \\fileserver look the most likely to work. If only I could work out why it only works if the browser is on the same machine as the web server.
 
Thanks for everyone's input on this. The code has kicked into gear and is now working as per my original posting, using \\fileserver and without server.mappath. It's possible one of the admin guys changed something else on the web server, but I switched it to use Basic Authentication, which seems on the face of it to have fixed the problem. The users are now domain users (on a third EXTERNAL domain), but it's working so I'm happy.

Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top