Recipe 12.26. Configuring FTP User IsolationProblemYou want to create an FTP site that gives each user her own virtual root directory. SolutionUsing a graphical user interfaceFirst, you need to create the appropriate folder structure using Windows Explorer:
Now create a new FTP site that uses FTP User Isolation to map each user's account to their own FTP virtual root:
Using a command-line interfaceFirst, create a folder structure as described above. Then use the following command to create a new FTP site named My FTP Site with root directory C:\FtpHome and IP address 172.16.12.50, and implement FTP user isolation: > iisftp /create C:\FtpHome "My FTP Site" /i 172.16.12.50 /isolation Local Using VBScript' This code creates a ftp site. ' ------ SCRIPT CONFIGURATION ------ strComputer = "<ServerName>" ' computer to connect to strSiteName = "<SiteName>" ' web site description strRootDir = "<RootDirectory>" ' root directory for the ftp site strPort = "21" ' port for the web site ' The following parameters are optional ' strIP = "<IPAddress>" ' IP address used for the site ' strHostHeader = "<HostName>" ' host header name for the site strSiteID = "<SiteID>" ' site ID (default is to auto-generate) ' ------ END CONFIGURATION --------- set objIIS = GetObject("IIS://" & strComputer & "/msftpsvc" ) set objNewFtpServer = objIIS.Create("IIsFtpServer",strSiteID) objNewFtpServer.ServerComment = strSiteName objServerBindings = Array(0) objServerBindings(0) = strIP & ":" & strPort & ":" & strHostHeader objNewFtpServer.ServerBindings = objServerBindings objNewFtpServer.UserIsolationMode = 1 ' 0 = No isolation ' 1 = Isolation ' 2 = AD isolation objNewFtpServer.SetInfo set objNewDir = objNewFTPServer.Create("IIsFtpVirtualDir", "ROOT") objNewDir.Path = strRootDir objNewDir.AccessRead = True objNewDir.SetInfo WScript.Echo "Successfully created ftp site " & objNewFtpServer.ServerComment DiscussionIIS 6 supports three different isolation methods:
The solution described in this recipe is for the Isolate users approach. For information on how to programmatically use the Isolate users using Active Directory approach, see MS KB 555205 (FTP User Isolation Using Active Directory Using Visual C#).
See AlsoMS KB 555018 (How To Set Up Isolated Ftp Site) |