Library tutorials & articles

Mastering IIS FTP

Virtual Directories/Physical Directories

In Part 1 we covered ways to use the hidden power of Microsoft's FTP server product. We talked about ways to leverage virtual directories along with Windows user accounts.

Today I want to take this one step further and discuss how to work with the IIS FTP quirks with using virtual directories as ... yes, virtual directories. Because Microsoft has t his unique way to utilizing virtual directories to offer more control, it also means that simply using virtual directories for their original purpose isn't as obvious as it should be.

Rule #3: A Virtual Directory created in IIS FTP isn't seen by a FTP program

If we want to create a virtual folder that points to a different location on a server, one of the first things we will notice is that if we create the virtual directory in IIS FTP and then use a FTP client to log in, we won't see the folder!! We can use ChgDir if our FTP client supports it and type in the name of the vdir but that's often times not good enough. We want to actually see it.

Let me explain it further. Consider the following folder structure where d:\domains\mysite\ is the FTP root path:

d:\domains\mysite\
d:\domains\mysite\images\
d:\domains\mysite\bin\
d:\domains\mysite\admin\

Now, let's create a virtual directory in IIS FTP called downloads which will point to: e:\downloads\

When we log into our FTP account, we will see images, bin and admin but we won't see downloads.

Why is that? Since virtual directories aren't always used for their original purpose, as we saw in Part 1, they don't automatically appear. The other reason is that FTP programs will scan the files and folders on disk to determine what to display. Since virtual directories don't reside at the folder level, they won't be shown with the rest of the folders.

So what do we do? Fortunately the solution is simple.

Tip #2: Create an empty “physical” directory to have a “virtual” directory appear in a FTP program

Since the FTP client program will check for files and folders on disk, simply create an empty folder on disk where the virtual directory should show up. In my example above, it means creating an empty folder called d:\domains\mysite\downloads\. Now, after you log into this FTP account with your FTP program, you will see images, bin, admin and downloads . If you double click on downloads you will be taken to e:\downloads because the virtual directory in IIS FTP will take precedence.

Rule #4: If both a Virtual Directory and Physical Directory exist, the Virtual Directory takes precedence

In my example above, I've created a “virtual“ folder which redirects to another location on the server, and a “physical“ folder so that it will show up in my FTP program. Even if I put files in the empty downloads folder, I won't be able to access them by double clicking on the downloads folder. Instead of being directed to d:\domains\mysite\downloads\ (physical folder) I will be directed to e:\downloads\ (virtual folder).

In summary, when creating a virtual directory that should show up in the FTP client program, make sure to create an empty physical directory to match.

Comments

  1. 03 Aug 2009 at 14:58

    Great article. Look forward to user isolation. I actually pointed to your article from my own blog. Thanks again.

  2. 07 Mar 2009 at 14:50
    Thanks Orcs!!! Excelent tutorial, just a pity that you have to create a dummy Master FTP location because users need list contents privalges. This means that i will have to know create individual user acccounts for all the virtual sites i have running!!! Will look at user isolation if this can be resolved better and hoping that iis 7 makes this job easier or may consider going down the LAMP route and getting into Apache, seems these days all the best jobs are know based around open source tech, ruby, php etc!!! Anyways, thanks again for a great tutorial!!!
  3. 05 Aug 2007 at 04:16

    Excellent how-to, thanks!

     

    Regards

    Matt

  4. 23 Dec 2006 at 10:42
    This was just what I was looking for. I'm running multiple websites on my w2k3 server but was in need for a good solution to excess them via FTP. The simplicity is amazing. Thanx for the readthru, keep up the good work!

  5. 08 Jun 2006 at 18:40
    This is great!  Easy to understand article, and works perfectly (at least for me!)

  6. 31 May 2005 at 10:03
     Wow! That easy. Thanx this one really solved a lot of problems for me!

    One question though, (Please note that I am a complete newby at this), Why does my servers performance drop (signifficantly!) every time a user uploads / downloads any item? On larger downloads this actually causes some of my sites to drop completely.

    Obviously this must have something to do with the priorities on the server, but how do I adjust these priorities if indeed that is where the problem lies?
  7. 26 Apr 2005 at 15:29

    Nice! Cheers for those extra tips, Eric

  8. 26 Apr 2005 at 00:13

    I've been using these techniques since NT 4.0's Option Pack.  People just don't know how powerful the built-in stuff is.  And now with quota management and AD, it can be very powerful in an ISP hosted environment (it's what I use).


    Another tip:  You can create sub-Virtual directories, but they must be from within the FTP's VDs.  I often create Unix-like links for users to get into certain directories of my domains.  For example, say we have a domain called "domain.com".  On my server, that would be:


    E:\Users\eric.duncan\domain.com\www\default.aspx


    Say I want to give Jim Bob access to this domain, but not to all of the domains under my username.  But there's a problem, the user already has access to their own directory:


    E:\Users\jim.bob\


    This user accesses their account via the IIS FTP service's virtual directory called "jim.bob":


    FTP Sites
    -- Public FTP
    ------ jim.bob (which points to the user's Home directory above)


    What I do is create an empty directory (described in this article) named the domain + lnk, but this directoy is in the user's normal Home directory:


    E:\Users\jim.bob\domain.com.lnk


    And then create a sub-virtual directory, named the same under the user:


    FTP Sites
    -- Public FTP
    ------ jim.bob
    ---------- domain.com.lnk


    Now when the user logs in, they will see their home directory, with a new directory named domain.com.lnk.  Changing directories to this location forces the FTP's virtual directory to change it's location to my directory:


    E:\Users\eric.duncan\domain.com\www\


    Just remember to give jim.bob access to that directory, else he will get an Access Denied.


    Oh, that was another tip: To set permissions, do it at the physical-directory level (as I've done above).  Mix it all with quotas, and there isn't a reason for me to use anything else.  

  9. 15 Feb 2005 at 09:05
    Thank you for the article.  It explains why I have used Microsoft FTP on my 2003 server for a year and never managed to land in the right directory!  Now I can take a good look at the structure and re-organise it!
  10. 01 Jan 1999 at 00:00

    This thread is for discussions of Mastering IIS FTP.

Leave a comment

Sign in or Join us (it's free).

Orcs Web

Related podcasts

  • Developer's Guide to IIS7

    Steve Schofield is an IIS expert working for webhost ORCS Web. Steve and his team are responsible for such sites as Channel9, ASP.NET, weblogs.asp.net and ASP Alliance. As a member ASP Insiders and a IIS MVP - Steve knows his way around a web server. Steve sheds light on how the new features in I...

We'd love to hear what you think! Submit ideas or give us feedback