Programmatically Administering the Home Directory Property Sheet

   

Programmatically Administering the Home Directory Property Sheet

As shown in Figure 10.4, each virtual directory utilizes a home directory to point users to the files and directories comprising the FTP site. A virtual directory can be hosted either on the FTP server itself, or on a remote share. If the remote share option is chosen , you must also specify the credentials to be used when accessing the resource.

Figure 10.4. Default FTP Site Properties dialog boxHome Directory tab (local path ).

graphics/10fig04.gif

Additionally, you can specify the access permissions for the home directory and whether the directories should utilize an MS-DOS- or UNIX-style list.

Local Home Directory

To access content stored on the local machine, only the virtual directory's Path property must be assigned a value. Although these code examples demonstrate the use of the root virtual directory, you can also easily bind another existing virtual directory.

Querying the Local Path Property for an FTP Site's Root Virtual Directory Using Visual Basic

To find the current path associated with a particular FTP site, use the following Visual Basic code as a guide:

 Dim VirtualDirectory As IADs Dim ServerName As String Dim Index As Long Dim RetVal as String ServerName = "IIS_Server_Name" Index = Site_Index_Value Set VirtualDirectory = GetObject("IIS://"&ServerName&"/MSFTPSVC/"&Index& "/ROOT") RetVal = VirtualDirectory.Path Debug.Print RetVal 
Modifying the Local Path Property for an FTP Site's Root Virtual Directory Using Visual Basic

To programmatically vary the path assigned to an existing FTP site, use the following Visual Basic code:

 Dim VirtualDirectory As IADs Dim ServerName As String Dim Index As Long Dim NewVirtualDirPath As String ServerName = "IIS_Server_Name" Index = Site_Index_Value NewVirtualDirPath = "New_Path_for_Site" Set VirtualDirectory = GetObject("IIS://"&ServerName&"/MSFTPSVC/"&Index& "/ROOT") VirtualDirectory.Path = NewVirtualDirPath VirtualDirectory.SetInfo 

Remote Home Directory

To access content stored on a remote share, simply assign the virtual directory's path property to a valid UNC sharepoint (such as \\Server_Name\Share_Name), and define the credentials used for the connection by assigning values to UNCUserName and UNCPassword . The use of an FTP site remote home directory in the IIS 4.0 Internet Server Manager is shown in Figure 10.5.

Figure 10.5. Default FTP Site Properties dialog box ”Home Directory tab (remote path).

graphics/10fig05.gif

Querying the Remote Path Property and UNC Connection Information for a Site's Root Virtual Directory Using Visual Basic

Just as was the case with remote Web home directories, to view the credentials and path associated with a remote FTP home directory, use the following Visual Basic code:

 Dim VirtualDirectory As IADs Dim ServerName As String Dim Index As Long Dim RetVal As String ServerName = "IIS_Server_Name" Index = Site_Index_Value Set VirtualDirectory = GetObject("IIS://"&ServerName&"/MSFTPSVC/"&Index& "/ROOT") Debug.Print VirtualDirectory.Path Debug.Print VirtualDirectory.UNCUserName Debug.Print VirtualDirectory.UNCPassword 

Warning

Notice that you were able to obtain the username and password assigned to access the remote share. As a result of your ability to easily compromise this account information, do not use a privileged account for the UNCUserName and UNCPassword properties .


Modifying the Remote Path Property for a Site's Root Virtual Directory Using Visual Basic

To programmatically establish a new remote home directory for an FTP site, use the following Visual Basic code:

 Dim VirtualDirectory As IADs Dim ServerName As String Dim Index As Long Dim NewVirtualDirPath As String Dim NewVirtualDirUser As String Dim NewVirtualDirPassword As String ServerName = "IIS_Server_Name" Index = Site_Index_Value NewVirtualDirPath = "New_Path_for_Site" NewVirtualDirUser = "UNC_Credentials_Used_To_Establish_Connection" NewVirtualDirPassword = "UNC_Credentials_Used_To_Establish_Connection" Set VirtualDirectory = GetObject("IIS://"&ServerName&"/MSFTPSVC/"&Index& "/ROOT") VirtualDirectory.Path = NewVirtualDirPath VirtualDirectory.UNCUserName = NewVirtualDirUser VirtualDirectory.UNCPassword = NewVirtualDirPassword VirtualDirectory.SetInfo 

Directory Access Permissions

Although IIS uses NTFS permissions to manage access to resources, the ability to restrict permissions even further exists by assigning the appropriate Boolean value to the AccessRead and AccessWrite properties for the bound resource.

Although intended to restrict permissions for File Access Table (FAT) partitions, the AccessRead and AccessWrite properties apply only the most restrictive right when used with NTFS security. For example, if the NTFS permissions for the user account do not allow writes to the file system, regardless of the value of AccessWrite , you will not be able to write to the directory. Conversely, if the account utilized for accessing the site grants the user the ability to write to the file system, the user will only be able to write if the value of AccessWrite is assigned a True value.

In addition, you can specify by toggling the Boolean value assigned to the DontLog property whether you wish to log access to the bound resource.

Querying Directory Access Permissions and Logging Status Using Visual Basic

To determine whether a user can read or write a resource or whether the resource is subject to logging, use the following Visual Basic code:

 Dim VirtualDirectory As IADs Dim ServerName As String Dim Index As Long Dim RetVal as String ServerName = "IIS_Server_Name" Index = Site_Index_Value Set VirtualDirectory = GetObject("IIS://"&ServerName&"/MSFTPSVC/"&Index& "/ROOT") Debug.Print "Read:"&vbTab&vbTab&vbTab&vbTab&VirtualDirectory.AccessRead Debug.Print "Write:"&vbTab&vbTab&vbTab&vbTab& VirtualDirectory.AccessWrite Debug.Print "Logging Disabled: "&vbTab&vbtab&VirtualDirectory.DontLog 
Setting Directory Access Permissions and Logging Using Visual Basic

To set these properties, simply assign the AccessRead , AccessWrite , and DontLog properties to the appropriate Boolean value and call the IADs SetInfo method, as shown in the following Visual Basic code:

 Dim VirtualDirectory As IADs Dim ServerName As String Dim Index As Long Dim RetVal as String ServerName = "IIS_Server_Name" Index = Site_Index_Value Set VirtualDirectory = GetObject("IIS://"&ServerName&"/MSFTPSVC/"&Index& "/ROOT") VirtualDirectory.AccessRead = True VirtualDirectory.AccessWrite = True VirtualDirectory.DontLog = False VirtualDirectory.SetInfo 

Directory Listing Style

IIS offers two options for formatting the output from directory listings. To help illustrate and highlight the differences, consider the examples shown below.

MS-DOS directory listing style:

 ftp> dir *.exe 200 PORT command successful. 150 Opening ASCII mode data connection for /bin/ls. 11-05-97  03:25PM                20480 aceclcab.exe 06-02-98  07:44AM                44544 clspack.exe 10-27-97  06:19PM                38784 cpsdir.exe 03-18-99  08:09PM               100864 extract.exe 09-09-99  03:16PM                26896 hh.exe 03-18-99  08:09PM                17655 iextract.exe 08-26-97  12:06PM               315904 IsUninst.exe 06-02-98  07:29AM               154112 jview.exe 06-02-98  07:41AM                42496 setdebug.exe 06-13-97  06:46AM               298496 uninst.exe 10-14-96  02:38AM                22288 welcome.exe 06-02-98  07:29AM               147456 wjview.exe 226 Transfer complete. 618 bytes received in 0.02 seconds (30.90 Kbytes/sec) ftp> 

UNIX directory listing style:

 ftp> dir *.exe 200 PORT command successful. 150 Opening ASCII mode data connection for /bin/ls. -r-xr-xr-x   1 owner    group           20480 Nov  5  1997 aceclcab.exe -r-xr-xr-x   1 owner    group           44544 Jun  2  1998 clspack.exe -r-xr-xr-x   1 owner    group           38784 Oct 27  1997 cpsdir.exe -r-xr-xr-x   1 owner    group          100864 Mar 18 20:09 extract.exe -r-xr-xr-x   1 owner    group           26896 Sep  9 15:16 hh.exe -r-xr-xr-x   1 owner    group           17655 Mar 18 20:09 iextract.exe -r-xr-xr-x   1 owner    group          315904 Aug 26  1997 IsUninst.exe -r-xr-xr-x   1 owner    group          154112 Jun  2  1998 jview.exe -r-xr-xr-x   1 owner    group           42496 Jun  2  1998 setdebug.exe -r-xr-xr-x   1 owner    group          298496 Jun 13  1997 uninst.exe -r-xr-xr-x   1 owner    group           22288 Oct 14  1996 welcome.exe -r-xr-xr-x   1 owner    group          147456 Jun  2  1998 wjview.exe 226 Transfer complete. 858 bytes received in 0.29 seconds (2.96 Kbytes/sec) 

To set the directory listing style, simply assign an appropriate Boolean value to the MSDOSDirOutput property. When set to True, the MS-DOS directory listing style is used. By default, the IIS FTP service uses MS-DOS style directory listings. In general, however, you should use the UNIX directory listing style for a more seamless presentation to users in heterogeneous computing environments.

Querying Directory Listing Style Using Visual Basic

To find out which directory listing style has been configured for use on a specific resource, use the following Visual Basic code:

 Dim VirtualDirectory As IADs Dim ServerName As String Dim Index As Long ServerName = "IIS_Server_Name" Index = Site_Index_Value Set VirtualDirectory = GetObject("IIS://"&ServerName&"/MSFTPSVC/"&Index) Debug.Print VirtualDirectory.MSDOSDirOutput 
Setting Directory Listing Style Using Visual Basic

To set the directory listing style, simply set the MSDOSDirOutput property to the appropriate Boolean value, as shown in the following Visual Basic code:

 Dim VirtualDirectory As IADs Dim ServerName As String Dim Index As Long ServerName = "IIS_Server_Name" Index = Site_Index_Value Set VirtualDirectory = GetObject("IIS://"&ServerName&"/MSFTPSVC/"&Index) VirtualDirectory.MSDOSDirOutput = False VirtualDirectory.SetInfo 

   
Top


Windows NT. 2000 ADSI Scripting for System Administration
Windows NT/2000 ADSI Scripting for System Administration
ISBN: 1578702194
EAN: 2147483647
Year: 2000
Pages: 194
Authors: Thomas Eck

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net