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

Link to a file on an internal server 1

Status
Not open for further replies.

NewNetworkAdmin

Technical User
Sep 9, 2004
57
GB
Hi,

This seems a strange question - either its a stupid one and I shouldn't be asking it, or its really simple and I'm missing the point!!

I am currently setting up an Intranet which will eventually be an extranet (accessible by employees working outside the office - after authentication).

We want to make certain company documents accessible to everyone via the intranet/extranet. The problem is that the file server is not directly accessible through the extranet and I don't really want to put duplicates of the documents from our file server onto the extranet server.

Is there a way to link to the files on the file server via an HTML page on the extranet server?

I tried simply putting a <a href="... to the files I need. This works fine inside the network as the server is accessible. But if you try this from outside the network, the browser tries to connect a website with the name of our internal server!!

I'd appreciate any suggestions even the ones telling me how stupid I'm being (as long as reasons are given :))
 
maybe ur extranet server can connect to ur intranet server and using server side script map the drive (possible using ASP) and read the file from the mapped path...

Known is handfull, Unknown is worldfull
 
Thanks vbkris that sounds a good solution. Do you have the code to hand to map a network drive in ASP?

Looking on W3schools.com it mentions the different things you can do with the ASP drive object and ASP file object, but its not too clear (at least to me) how to map a drive.

Thanks for your help.
 
u have to use - Server.CreateObject("WScript.Network")

i dont have the code with me currently give me some time. u could also piece the code together (any VB code will work in ASP)...

Known is handfull, Unknown is worldfull
 
here is the code:
Set ws = Server.CreateObject("WScript.Network")
ws.MapNetworkDrive "L:", "\\System\c", false, "Domain\username","password"

ws.RemoveNetworkDrive "L:",true


Known is handfull, Unknown is worldfull
 
Thank vbkris. I've got the intranet server mapping a network drive to the file server now. But I still have a problem. I would like the user to click on a link in their web browser and be taken to the file they want.

If I map to the file server as drive L: and put a link on the web page as L:\files\file.txt, then the browser tries to connect to a local L: drive.

How can I tell the browser to go to the server, then go to THE SERVER'S L: drive?

Thanks for all your help
 
u may have to do this:

when the user clicks for a file, u have to use ASP to copy the file from L:\ to ur External server (which has access to L:\) and allow the user to download the file on the External Server...

Known is handfull, Unknown is worldfull
 
ok, I've almost solved this. I'm not actually using your code vbkris. I'm just copying the file from \\servername\path... to the external server, then getting asp to create a link to that file for the user to click on.

The one problem I still have is this...

I'm using this code to check that the file requested exists before actually copying it:

set fso = CreateObject("Scripting.FileSystemObject")

if NOT (fso.FileExists(strFileSource)) then

tell the user it doesn't exist
exit function
end if

There are some files that I am 100% certain that they exist, yet FileExists says they don't.

I thought this could be a permissions issue, but added my username AND IUSR_servername AND IWAM_servername AND Anonymous Logon group to the file with full permissions and it still didn't work.

I am NOT using anonymous logon for the web site, so surely all I need to copy the file is ther user's permission on that file? Does the ASP copy code run with the user's permissions or anonymously? Either way I added all the usernames I could think of that might affect it.

I'm so close to getting this to work. Its really frustrating. Any help greatly appreciated.


 
response.write strFileSource

what does it say???

Known is handfull, Unknown is worldfull
 
A valid path to the file eg. \\servername\test\test.txt

This works with some files but not with others. If I copy this into either a web browser or into the Start->Run box it opens the file
 
\\servername\ - its the external server name right?

>>ok, I've almost solved this. I'm not actually using your code vbkris


can i have the code???

Known is handfull, Unknown is worldfull
 
servername is the name of the internal server...Here is the code:
Code:
function CopyFile(strFileSource, strFileDestination, strError)

    on error resume next

    if strFileSource = "" OR strFileDestination = "" then
		
        strError = "Error - You must supply both a source and a destination"
        exit function
    end if

    set fso = CreateObject("Scripting.FileSystemObject")

    if NOT (fso.FileExists(strFileSource)) then

        strError = "Error - Source file does not exist"
        exit function
    end if

    if strError = "" then

        Set f2 = fso.GetFile(strFileSource)
        f2.Copy(strFileDestination)
        Set f2 = nothing
    end if

    Set fso = nothing
end function

This is called using:

Code:
CopyFile srcString, destFolder, ""

where srcString = \\internalServer\test\test.txt

and destFolder = C:\inetpub\
The problem is in the fileExists section. If I response.write(strError) I get the "Error - Source file does not exist"

P.S. I've removed some of the debugging and user error handling like printing the error for the user to see as this only complicates matters at this stage and I don't know why you have to pass strError TO the copyFile function. This wasn't originally my code. I haven't changed that yet.
 
\\internalServer\test\test.txt

wont work in FSO, thats why i used the Network method...

Known is handfull, Unknown is worldfull
 

why's that? As I say, it works for some files, but not others.

I'll try it with your original code and let you know how it goes.
 
I've tried using the drive map code as well and it hasn't really made any difference.

I can access any file on the server now if I type my username and password in when mapping the drive. If I leave the username and password out altogether I can access the files that I could before and cannot access the problematic ones. I get an Access Denied error on the
Code:
ws.MapNetworkDrive "L:", "\\System\c", false, "Domain\username","password"
line.

I don't mind using this approach, but I'd prefer it if the user's didn't have to type in their passwords each time they want to download a file. Is there a way I can retrieve the user's password and insert it in the code. I know you can use
Code:
Request.ServerVariables ("LOGON_USER")
for the username, but what about the password?

Thanks for your help
 
nope, u cant do that...

Known is handfull, Unknown is worldfull
 

So the only option is to prompt the user for their password before downloading each file? No other ways???
 
yup, thats the closest...

Known is handfull, Unknown is worldfull
 
Thanks for all your help vbkris. It works!! Now the user is prompted for their password and the external server maps a drive to the internal one using the user's credentials and the ws.MapNetworkDrive code.

Thanks again.......and have a star.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top