Programmatically Administering the FTP Site Property Sheet

   

Programmatically Administering the FTP Site Property Sheet

The FTP site property sheet, shown in Figure 10.1, allows you to define the description, IP address, TCP port, number of connections, and logging properties for the FTP site.

Figure 10.1. Default FTP Site Properties dialog box ”FTP Site tab.

graphics/10fig01.gif

By manipulating the properties in this sheet, you can configure the basic identification for the site. As in an IIS Web site, you can assign a site an alternate TCP port or IP address to allow multiple FTP sites to be hosted on a single server. It is important to note, however, that unlike an IIS Web server, you do not have the ability to implement host headers. Although this may seem like a tremendously limiting factor, with a bit of creativity, this obstacle is easily overcome . By simply assigning each site a unique TCP port and creating a link to the site on a Web page, you can obtain easy access to the FTP site simply by using an HTML browser.

Manipulating Site Identification Properties

The identification frame allows you to define the server description, IP address, and TCP port to be used with the site. Each site should maintain unique values for at least two of these properties.

Manipulating the FTP Site Description

To manipulate an FTP site's description, you simply need to assign a unique value to the ServerComment property.

Tip

Although you can assign non-unique values for the site description (the Metabase references sites by index number, not ServerComment ), the use of non-unique values makes it impossible to identify one site from another and should be avoided .


Querying the ServerComment Property Using Visual Basic

To find the current description for an FTP site, use the following Visual Basic code:

 Dim Site As IADs Dim ServerName As String Dim Index As Long ServerName = "IIS_Server_Name" Index = Site_Index_Integer Set Site = GetObject("IIS://"&ServerName&"/MSFTPSVC/"&Index) Debug.Print Site.ServerComment 
Setting a New Value for the ServerComment Property Using Visual Basic

Use the following Visual Basic code to set a new description for the FTP site:

 Dim Site As IADs Dim ServerName As String Dim Index As Long Dim NewServerComment as String ServerName = "IIS_Server_Name" Index = Site_Index_Integer NewServerComment = "New_Server_Comment_String" Set Site = GetObject("IIS://"&ServerName&"/MSFTPSVC/"&Index) Site.ServerComment = NewServerComment Site.SetInfo 
Manipulating IP Addresses and TCP Ports

If the IP address/TCP port pair conflicts with another site, IIS will not allow you to start the site. FTP sites cannot use host headers, thus you must use a unique IP address/TCP port combination for each site on a given machine.

To address this issue, you could use the same IP address and simply alter the TCP port assigned to each site. However, this approach causes issues for non-browser-based FTP clients because the user may not know how to connect to an FTP site running on a TCP port other than 21 in their client software.

For example, using the Windows NT command line FTP client, you cannot specify an alternate port unless you use the Open command, as follows :

 C:\>ftp ftp> open Server_Name 5000 Connected to Server_Name. 220 Server_Name Microsoft FTP Service (Version 4.0). User (Server_Name:(none)): anonymous 331 Anonymous access allowed, send identity (e-mail name) as password. Password: 230 Anonymous user logged in. ftp> 

Although this is certainly well within the grasp of even the least sophisticated user, many users may be used to simply specifying the FTP site name on the command line:

 C:\>ftp server_name 

While the use of alternate TCP ports is efficient in terms of IP address allocation, it forces the user to have a basic understanding of TCP ports and how they affect the chosen FTP client.

If you are implementing FTP sites for non-browser-based FTP clients, you can assign multiple IP addresses to any Windows NT machine with a statically assigned IP address by clicking the Advanced button while editing the properties of the TCP/IP protocol. You can then create a unique DNS entry for the IP address assigned to each individual FTP site. This allows users to simply FTP to a specific site name with little regard for non-default TCP port configurations in their client software.

No matter which approach you choose, the manipulation of the IP address and TCP port is handled by the ServerBindings property. This property is a variant array of strings with each string formatted as follows:

 IP_Address:TCP_Port: 
Querying ServerBindings Using Visual Basic

If you wish to find the IP address and TCP port assigned to the bound site, use the following Visual Basic code:

 Dim Site As IADs Dim ServerName As String Dim SiteIndex As Long ServerName = "IIS_Server_Name" SiteIndex = Site_Index_Value Set Site = GetObject("IIS://"&ServerName&"/MSFTPSVC/"&SiteIndex) For Each Binding In Site.ServerBindings     Debug.Print Binding Next 
Setting ServerBindings Using Visual Basic

To set the identification of the site to an alternate port or IP address, use the following Visual Basic code:

 Dim Site As IADs Dim ServerName As String Dim SiteIndex As Long Dim NewBindingArray As Variant Dim IPAddress As String Dim TCPPort As Long ServerName = "IIS_Server_Name" SiteIndex = Site_Index_Value IPAddress = "xxx.xxx.xxx.xxx" TCPPort = TCP_Port_Number NewBindingArray = Array(IPAddress&":"&TCPPort&":") Set Site = GetObject("IIS://"&ServerName&"/MSFTPSVC/"&SiteIndex) Site.ServerBindings = NewBindingArray Site.SetInfo 

Note

This code will create an array and assign it to the ServerBindings property .


Manipulating Connection Properties

To prevent over-saturation of server and network resources, you may wish to limit the number of connections to a given FTP site. If limits are imposed, you will want to define a connection timeout to allow idle connections to be recycled for use by other users.

Querying Maximum Connections Using Visual Basic

Using the MaxConnections property of the IIsFTPServer interface, you can find the maximum number of simultaneous connections allowed for a particular site.

Use the following Visual Basic code as a guide:

 Dim Site As IADs Dim ServerName As String Dim Index As Long Dim RetVal as Long ServerName = "IIS_Server_Name" Index = Site_Index Set Site = GetObject("IIS://"&ServerName&"/MSFTPSVC/"&Index) RetVal = Site.MaxConnections Debug.Print RetVal 

Tip

A setting of 2000000000 allows unlimited connections to the server .


Setting Maximum Connections Using Visual Basic

To set the maximum number of connections for a given FTP site, use the following Visual Basic code:

 Dim Site As IADs Dim ServerName As String Dim Index As Long Dim NewMaxConnections as Long ServerName = "IIS_Server_Name" Index = Site_Index NewMaxConnections = Maximum_Number_of_Connections Set Site = GetObject("IIS://"&ServerName&"/MSFTPSVC/"&Index) Site.MaxConnections = NewMaxConnections Site.SetInfo 

Manipulating Connection Timeout

Using the ConnectionTimeout property, you can specify the amount of idle time (in seconds) before a user's FTP connection is closed.

Querying Connection Timeout Using Visual Basic

To find the amount of time an FTP connection is permitted to remain idle before it is closed, use the following Visual Basic code:

 Dim Site As IADs Dim ServerName As String Dim Index As Long Dim RetVal as Long ServerName = "IIS_Server_Name" Index = Site_Index Set Site = GetObject("IIS://"&ServerName&"/MSFTPSVC/"&Index) RetVal = Site.ConnectionTimeout Debug.Print RetVal 
Setting Connection Timeout Using Visual Basic

To specify a new connection timeout value (in seconds) for the ConnectionTimeout property, use the following Visual Basic code:

 Dim Site As IADs Dim ServerName As String Dim Index As Long Dim ConnectionTimeout as Long ServerName = "IIS_Server_Name" Index = Site_Index_Value NewConnectionTimeout = Connection_Timeout_in_Seconds Set Site = GetObject("IIS://"&ServerName&"/MSFTPSVC/"&Index) Site.ConnectionTimeout = NewConnectionTimeout Site.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