Programmatically Administering the Messages Property Sheet

   

Programmatically Administering the Messages Property Sheet

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.

Figure 10.3. Default FTP Site Properties dialog boxMessages tab.

graphics/10fig03.gif

Programmatically, you can manipulate these settings by assigning values to the GreetingMessage , ExitMessage , and MaxClientsMessage properties.

Greeting Message

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> 
Querying Current Greeting Message Using Visual Basic

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 
Setting New Greeting Message Using Visual Basic

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 

Exit Message

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 
Querying Current Exit Message Using Visual Basic

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 
Setting New Exit Message Using Visual Basic

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 

Maximum Connections Message

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 graphics/ccc.gif mirror site at ftp2.ecommerce2000.com Connection closed by remote host. 
Querying Current Maximum Connections Message Using Visual Basic

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 
Setting New Current Maximum Connections Message Using Visual Basic

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


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