Access Protocol

Access protocol contains operations that were executed in the repository by different users. The IAuditLog interface is used to work with access protocol; the interface can be obtained using the IMetabaseSecurity.OpenAuditLog method.

All records in access protocol can be divided into two types:

  1. Repository connection (session) records. To get records, use the IAuditLog.OpenLogons method.

  2. Records about user actions within a repository connection. To get records, use the IAuditLog.OpenOperations method.

The example of getting session information:

Sub GetLogonsFromAuditLog;
Var
    MB: IMetabase;
    MbSec: IMetabaseSecurity;
    AL: IAuditLog;
    ALogon: IAuditLogons;
    d, d1: DateTime;
    Lic: Object;
Begin
    MB := MetabaseClass.Active;
    // Get license to be able to work with the security manager
    Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
    MbSec := MB.Security;
    // Open access protocol
    Al := MbSec.OpenAuditLog;
    ALogon := AL.OpenLogons(False);
    Debug.WriteLine("Repository sessions: " + MB.Name);
    // Display information about current repository sessions in the console
    While Not ALogon.Eof Do
        Debug.Write("   Session: " + ALogon.Session.ToString + " | ");
        d := DateTime.FromDouble(ALogon.Stamp);
        d1 := DateTime.FromDouble(ALogon.StampOut);
        Debug.WriteLine(d.ToString + " - " + d1.ToString);
        ALogon.Next;
    End While;
    // Check in license
    Lic := Null;
End Sub GetLogonsFromAuditLog;

The example of getting information about operations executed within the session. Session key is sent as an input parameter:

Sub GetOperationsFromAuditLog(Session: Integer = 0);
Var
    MB: IMetabase;
    MbSec: IMetabaseSecurity;
    AL: IAuditLog;
    AOperat: IAuditOperations;
    d: DateTime;
    Lic: Object;
Begin
    MB := MetabaseClass.Active;
    // Get license to be able to work with the security manager
    Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
    MbSec := MB.Security;
    // Open access protocol
    AL := MbSec.OpenAuditLog;
    // If 0 is sent in the Session parameter take key of the  current session
    If Session = 0 Then
        Session := MB.LogonSession.Key;
    End If;
    // Create a list of operations
    AOperat := AL.OpenOperations(Session);
    // Display information about operations in the console
    Debug.WriteLine("Repository: " + MB.Name + ". Session No.: " + Session.ToString);
    Debug.WriteLine("Operations:");
    While Not AOperat.Eof Do
        d := DateTime.FromDouble(AOperat.Stamp);
        Debug.WriteLine("Repository object: " + AOperat.ObjectName + '(' + AOperat.ObjectId + ") " + d.ToString + ' ' + AOperat.Name);
        AOperat.Next;
    End While;
    // Check in license
    Lic := Null;
End Sub GetOperationsFromAuditLog;

See also:

Working with Security Manager