Using OpenAudit to save my hair… :-)

At the moment I’m doing old school Notes development and needed to implement audit logging the in application. What better and easier to do than to head over to OpenNTF, grab the latest version of OpenAudit and implement it. Given I had some issues with some form aliases which I need to talk to Chad Schelfhout about it took me all of 90 minutes to implement. The component is now seamlessly embedded in the application – nice, quick and easy…

For me the the number one benefit of using open source is to be able to tweak the code to fit the exact problem domain. When creating applications I like to keep all databases for the application in a separate directory and hence group associated databases. When doing this it makes sense that the databases can automatically find the other databases of the application thus eliminating the need for additional configuration. This goes for Julians OpenLog application as well as OpenAudit. I previously implemented this for OpenLog and hence needed to do the same for Open Audit.

It proved very easy. A simple hack of the setAuditDb-method in the “Open Audit”-script library made it possible. Now when specifying “*/” at the start of the path name in the audit configuration (e.g. */OpenAudit.nsf) the method will assume that the database can be found in the same directory as the calling database.

My changes are in bold:

Public Sub setAuditDb(sServer As String, Byval sDatabase As String, sReplicaID As String)
   On Error Goto ErrorHandler
   If ( dbAudit Is Nothing ) Then
      If sServer = "*" Then
         sServer = System.ThisDatabase.Server
      End If
      If Left(sDatabase, 2) = "*/" Then
         'get database relative to current directory
         Dim session As New NotesSession
         Dim current_directory As String
         Dim sep As String
         If Left(session.Platform, 3) = "Win" Then
            sep = ||
         Else
            sep = |/|
         End If
         current_directory = Strleftback(System.ThisDatabase.FilePath, sep)
         sDatabase = current_directory + sep + Right(sDatabase, Len(sDatabase)-2)
      End If

      Set dbAudit = New NotesDatabase( sServer, sDatabase )
      If dbAudit.isopen Then

      Else
         Call dbAudit.OpenByReplicaID( sServer , sReplicaID )
         If dbAudit.isopen Then
         Else
            Set dbAudit = System.ThisDatabase
         End If
      End If
   End If

   Exit Sub

   'Catches any invalid Replica IDs, and will uses the current database then
   errorHandler:
   Set dbAudit = System.ThisDatabase
   Exit Sub
End Sub

7 thoughts on “Using OpenAudit to save my hair… :-)”

  1. Well what I wanted to discus with you was that I had some strange behavior where the AuditForm field was incorrectly calculated for my OpenAudit Configuration form. The form is called Workflow and had also Workflow as an alias (simply entered as “Workflow|Workflow” in the form property box).

    For some reason (I haven’t been able to reproduce it afterwards) the lookup key in the “(Open Audit Config)”-view got messed up and hence I didn’t get any audit logs generated. After figuring out that this was the issue I removed the alias and re-save the form which resolved the issue. Then I added the form alias once again but then I was unable to reproduce the issue.

    I’ll let you know if I find a consistent way to reproduce. Thanks you to a great component and for saving my hair! 🙂

    P.S.: Nicely commented code… 😉

    Like

  2. I found the issue with alias and also fixed issue with case in form name. Will be fixed with 1.2.0 which I am testing and documenting now.

    The relative path has been added for both the LotusScript and Log list using Formula.

    Like

  3. Quote:"I am trying to configure open-audit in windows server domain environment. I can’t configure LDAP properly. pls guide"

    That problem has definitively to do with Open-Audit!

    Like

Comments are closed.