views:

303

answers:

3

I'm trying to something pretty simple but am having headaches with it. I'm pretty sure all I have here is a permissions issue I don't know how to solve but I could be wrong.

Here is my scenario... I have 3 servers...

  1. Server A - Web Server (Windows 2003) - Anonymous Access Enabled
  2. Server B - Red 5 Media Server
  3. Server C - NAS

The website on Server A allows for recording/uploading of video to Server B where the video is processed/transcoded. A Cron job on Server B then moves the videos over to Server C for storage.

Users can then watch their videos from Server A via a virtual directory thats been set up in IIS that points to Server C and connects as a domain user account.

I need to some how use the ASP File System Object to get the size of a folder on Server C that contains the videos.

I've mapped the parent folder of the folder on Server C where the videos are stored to a drive letter on Server A using a UNC path (\servername\videos).

I've tried using the FileSystemObject's folderExists() method for debugging purposes and it returns false if I pass in the mapped letter drive or a UNC path. It gives a path not found error. Just to be sure I did a response.write of the path being passed into the folderExists() method and it is the correct path. All of this leads me to believe this is really a permissions issue which I just don't know how to solve.

Thanks, Ryan

+1  A: 

You need to work with the FSO.Drives collection to get to your NAS. Have a look at this article (just googled it but it seems ok):

http://www.stardeveloper.com/articles/display.html?article=2001050301&page=1

Try running this and seeing if you drives are available, should help narrow down if its a permissions problem

<%

Dim fso
Set fso = Server.CreateObject("Scripting.FileSystemObject")

Dim drives
Set drives = fso.Drives

Dim isReady

For Each drive in drives
    isReady = drive.IsReady

    If isReady Then
        Response.Write "DriveLetter: " & drive.DriveLetter & "<br>"
        Response.Write "Path: " & drive.Path & "<br>"
        Response.Write "FileSytem: " & drive.FileSystem & "<br>"
        Response.Write "TotalSize: " & drive.TotalSize & "<br>"
        Response.Write "FreeSpace: " & drive.FreeSpace & "<br>"
    Else
        Response.Write "Driv Letter: " & drive.DriveLetter & "<br>"
        Response.Write drive.Path & "<br>"
        Response.Write "No other information available."
    End If
Next

%>

Have a play with that and see if you are still having problems, if so we will dig a bit deeper :)

Pete Duncanson
Thanks Pete. After running this bit of code only the local drives show up in the list printed out. I don't even get the info from your ELSE clause to print. It would appear that the mapped drive isn't even in the drives collection returned by the fso.Drives call. Explains why I'm getting the path not found error I guess.
Ryan
Hmmm, well annoyingly thats all the drives you have to play with via FSO. Wonder if you can give IUSR access to the parent folder and if it would work with a UNC then? I fear that UNC are not allowed though. Worth a shot? The else clause will only fire if a drive is busy/not ready ie your floppy drive does not have a disk in it, remember those? :)
Pete Duncanson
A: 

Not sure if this is the right thing to do but to remedy this I had to map the network drive via ASP (as the IUSR_machine) account like so...

dim objNetwork

Set objNetwork = CreateObject("WScript.Network") 
objNetwork.MapNetworkDrive "X:", "UNC path", "profile", "user", "password"

objNetwork.RemoveNetworkDrive "X:"
set objNetwork = nothing

Then I was able to access the mapped drive letter (X in this case) via the FileSystemObject.

Ryan
This is dangerous aside from assuming the sysadmin doesn't use drive X for anything else (which I guess is managable) what happens if multiple requests on the server runs this code? Either the Map attempt will fail or X will get unmapped prematurely.
AnthonyWJones
+2  A: 

Mapped network drives are no use to you in ASP on IIS6 since they are part of a user profile. User profiles are not fully loaded in services like IIS6.

Assuming a pure ASP environment (you can't install other dlls etc) then you will need the anonymous user to have access to the network share where the videos are stored and use the UNC path.

Now typically the IUSR account is local guest account which has no access to the network. You will need to create a user on the domain that the NAS belongs to and specify that users credentials as the anonymous user account for those pages that need to do your "Get Size" task ( you don't need change anonymous user for the whole application).

The foregoing assumes Server A is a member of the same domain as Server C. If not then you need to create user on the domain the Server A belongs to as well that mirrors the one on Server C including its password (or jump through trust relationship hoops).

With that in place you can go ahead and use FileSystemObject.

AnthonyWJones
Absolutely correct. I didn't think of the problem you mentioned. Your answer did do the trick though. Thank you very much.
Ryan