IMetabaseCustomEvents.OnBeforeLogon

Syntax

OnBeforeLogon(Args: IMetabaseOnBeforeLogonArgs);

Description

The OnBeforeLogon method implements the event that occurs before repository connection using web service.

Comments

The method must be redetermined in a custom class. The method use allows for redetermining repository connection parameters or executing any additional actions on connection.

For repository connection, the OpenMetabase operation is used.

If the handler throws an exception, its text will be available after executing the OpenMetabase operation.

Example

Generally, the specified example represents the class that can be used to handle connection event to repository from web service. The event handles two connection conditions. If none of the conditions is satisfied, connection is canceled, and the web service throws an exception.

Public Class CustomEvents: ForeMetabaseCustomEvents
    Public Sub OnBeforeLogon(Args: IMetabaseOnBeforeLogonArgs);
    Var
        Def: IMetabaseDefinition;
        SecPackage: ISecurityPackage;
        Creds: IPasswordCredentials;
    Begin
        If <Connection condition 1> Then
            Args.Handled := False;
            Args.AllowLogon := True;
            Args.ResultMetabase := Args.Metabase;
        Elseif <Connection condition 2> Then
            Args.Handled := True;
            Args.AllowLogon := True;
            Def := Args.Metabase.Definition;
            //...
            //Change connection parameters
            ///...
            SecPackage := New StandardSecurityPackage.Create;
            Creds := SecPackage.CreateCredentials(AuthenticationMode.Password) As IPasswordCredentials;
            Creds.UserName := (Args.Credentials As IPasswordCredentials).UserName;
            Creds.Password := "new password";
            //...
            //Set up credentials
            //...
            Args.ResultMetabase := Def.Open(Creds);
        Else
            Args.Handled := True;
            Args.AllowLogon := False;
            Raise New Exception.Create("Connection conditions are not satisfied. Contact the administrator.");
        End If;
    End Sub OnBeforeLogon;
End Class CustomEvents;

See also:

IMetabaseCustomEvents