Various messages can be displayed upon successful connection or termination of an FTP session. As shown in Figure 10.3, the Messages property sheet implements three types of messages for an FTP site: Welcome, Exit, and Maximum Connections.
Programmatically, you can manipulate these settings by assigning values to the GreetingMessage , ExitMessage , and MaxClientsMessage properties.
The FTP site greeting message is the message displayed immediately after successful user authentication. This value is stored in the Metabase as an array of strings assigned to the GreetingMessage property. Each string in the array represents an individual line of text to be displayed to the user.
C:\>ftp server_name Connected to server_name.eCommerce2000.com. 220 server_name Microsoft FTP Service (Version 4.0). User (server_name.eCommerce2000.com:(none)): anonymous 331 Anonymous access allowed, send identity (e-mail name) as password. Password: 230-Welcome to ftp.eCommerce2000.com! 230- 230-Using this site, you can download our 230-analysis of E-Commerce technological 230-enhancements for the financial industry. 230- 230-Feel free to navigate to the Public 230-directory to download our latest reports. 230- 230-If you should require technical assistance, 230-please feel free to drop us an e-mail at 230-ftp_techsupport@ecommerce2000.com 230 Anonymous user logged in. ftp>
To find the greeting message used upon a successful connection request, 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 MessageLine in Site.GreetingMessage Debug.Print MessageLine Next
To set a new greeting message, you must create an array of strings that will represent the message. Use the following Visual Basic code as a guide:
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) Site.GreetingMessage = Array("Greeting_Line_1","Greeting_Line_2","Greeting_Line_3") Site.SetInfo
Unlike the GreetingMessage property, ExitMessage consists of a single string displayed just before terminating the user's FTP session. If you want to implement such a feature for an FTP site, simply assign an appropriate string to the ExitMessage property, as follows :
ftp> bye 221 Thanks for visiting ftp.eCommerce2000.com
To find the current string used upon FTP connection termination, 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) Debug.Print Site.ExitMessage
To set a new message to be used upon termination of FTP client connections, use the following Visual Basic code:
Dim Site As IADs Dim ServerName As String Dim SiteIndex As Long Dim NewExitMessageString as String ServerName = "IIS_Server_Name" SiteIndex = Site_Index_Value NewExitMessageString = "FTP_Session_Termination_Text" Set Site = GetObject("IIS://"&ServerName&"/MSFTPSVC/"&SiteIndex) Site.ExitMessage = NewExitMessageString Site.SetInfo
If a user accesses the site when there are no available connections, a message can be displayed to either redirect the user to a mirror site, or perhaps simply apologize for the inconvenience. You can perform such an action by assigning the MaxClientsMessage property a string value representing the desired message.
Connected to server_name.ecommerce2000.com. 421 The maximum number of connections for this site has been reached. Please visit our mirror site at ftp2.ecommerce2000.com Connection closed by remote host.
To view the message issued to the client when the server has reached its maximum number of connections, 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) Debug.Print Site.MaxClientsMessage
To programmatically set the value of the string issued to the client when the server has reached its maximum number of connections, use the following Visual Basic code:
Dim Site As IADs Dim ServerName As String Dim SiteIndex As Long Dim MaxConnectionsString as String ServerName = "IIS_Server_Name" SiteIndex = Site_Index_Value MaxConnectionsString = "String_Passed_To_Client_When_Maximum_Connections_Reached" Set Site = GetObject("IIS://"&ServerName&"/MSFTPSVC/"&SiteIndex) Site.MaxClientsMessage = MaxConnectionsString Site.SetInfo
Top |