The many ways to list the contents of a directory

Word Count: 402

Let me start off by saying that this does not just relate to using cfdirectory but really any tag or function that deals with some type of absolute path. I came across this problem at work as we were trying to list the contents of a directory that resides on a remote machine. First let's take a look at the solution if we were trying to do this on our local machine. Here we can either hard code the exact location of the directory or if we know its right below the directory we are working with we can expand the current path.

This is fairly straight forward so far because we are dealing with local machine resources. When we start talking about a remote machine we are getting into account privileges on a domain. I am the first to tell you I am not an expert when it comes to server administration so If I explain something wrong call me out on it. In a default ColdFusion installation the service is run under the local system account and that usually will not have any privileges to outside resources. You either need to grant permissions to that account or you need to create a new account that has the necessary permissions. Once you have that done you can start working with outside resources.

Another thing to remember here is that we are working with absolute paths. In our case we had a virtual directory in IIS pointing to a share drive. Even though this is browsable you can not use "/vdname" to list the contents of a directory. You can however use expand path with the virtual directory name to get the path. In the end that will expand out to the UNC path of the directory. Another option you can use the ip address of the machine. As you can see there are many ways to list the contents of a directory. In my case it was a permissions issue so I would always start will full permissions and work your way backwards.

Comments

#1 Posted By: tony petruzzi Posted On: 5/18/09 3:37 PM
it's important to note that if you plan on accessing unc shares with cfdirectory, that the coldfusion service must be configured to use a valid account that has access to the share and NOT configured to use the system account. the exception to this is if the share's security settings are configured to allow EVERYONE access.


Post Your Comment

Leave this field empty







Show Captcha

If you subscribe, any new posts to this thread will be sent to your email address.

Copyright © 2007 Dan Vega | BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.