PowerTCP SSH and SFTP for .NET
Banner Event
Example 




Raised when the server presents a banner during authentication.
Syntax
'Declaration
 
Public Event Banner As SshConnection.BannerEventHandler
'Usage
 
Dim instance As SshConnection
Dim handler As SshConnection.BannerEventHandler
 
AddHandler instance.Banner, handler
public event SshConnection.BannerEventHandler Banner
public: __event SshConnection.BannerEventHandler* Banner
public:
event SshConnection.BannerEventHandler^ Banner
Event Data

The event handler receives an argument of type BannerEventArgs containing data related to this event. The following BannerEventArgs properties provide information specific to this event.

PropertyDescription
Accept Set to false to refuse the banner and cancel authentication. Defaults to true.  
BannerText Gets the text of the banner sent by the server.  
Remarks
See the ComponentBase.SynchronizingObject property for important information on updating UI controls from within this event.
Example
The following demonstrates displaying the banner to the user and requesting permission to proceed with authentication.
private void ssh1_Banner(object sender, BannerEventArgs e)
{
    string prompt = string.Concat(e.BannerText.Trim(), Environment.NewLine, Environment.NewLine, "Continue with authentication?");
    if (MessageBox.Show(prompt, "Server presented a banner", MessageBoxButtons.YesNo) == DialogResult.No)
    {
        //Set to false to cancel Authentication
        e.Accept = false;
    }
}
Private Sub ssh1_Banner(ByVal sender As Object, ByVal e As BannerEventArgs) Handles ssh1.Banner
    Dim prompt As String = String.Concat(e.BannerText.Trim(), Environment.NewLine, Environment.NewLine, "Continue with authentication?")
    If MessageBox.Show(prompt, "Server presented a banner", MessageBoxButtons.YesNo) = System.Windows.Forms.DialogResult.No Then
        'Set to false to cancel Authentication
        e.Accept = False
    End If
End Sub
See Also

Reference

SshConnection Class
SshConnection Members


PowerTCP SSH and SFTP for .NET Documentation Version 7.0
© 2023 Dart Communications. All Rights Reserved.
Send comments on this topic