Retrieve A Database's Acl History

This LotusScript function takes a NotesDatabase object as an argument and
returns a list (Variant) of all entries in the db's ACL change history log (up
to the Notes-imposed maximum of 20). If no history is found, False is returned
instead.

This is the same list you get when performing a "File - Database - Access
Control - Log" from the Notes R5 Client. As this makes one call to the Win32
API, it will only work on the Win32 platform.

Here is a sample button script that displays the ACL change history for a
database in a Messagebox:

Sub Click(Source As Button)
Dim session As New NotesSession
Dim vHistory As Variant
Dim msg$

msg$=""
vHistory=GetACLHistory(session.CurrentDatabase)

If Not vHistory Then
Msgbox "There is no ACL change history for this database.", 48, "ACL History
Demo"
Else
Forall i In vHistory
msg$=msg$ & i & Chr(13) & Chr(10)
End Forall

Msgbox msg$, 0, "ACL History for " & session.CurrentDatabase.Title
End If
End Sub
' Notes API declares
Declare Sub OSPathNetConstruct Lib "nnotes" (Byval portName$, Byval
ServerName$, Byval FileName$, Byval retPathName$)
Declare Function NSFDbReadACL% Lib "nnotes" (Byval hDB&, hACL%)
Declare Function ACLGetHistory% Lib "nnotes" (Byval hACL%, hHistory%,
HistoryCount%)
Declare Function NSFDbOpen% Lib "nnotes" (Byval PathName$, hDB&)
Declare Function NSFDbClose% Lib "nnotes" (Byval hDB&)
Declare Function OSMemFree% Lib "nnotes" (Byval Handle%)
Declare Function OSLockObject& Lib "nnotes" (Byval nHandle&)
Declare Function OSUnlockObject% Lib "nnotes" (Byval nHandle&)

' Win32 API
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Byval pDest$,
Byval pSource&, Byval dwLength&)

Function GetACLHistory(db As NotesDatabase) As Variant
Dim hDb&, hLock&
Dim hHistory%, hACL%, nCount%, nLoop%
Dim Path$, History$, Hold$
Dim theList() As String

Hold$=""
Path$=Space(256)
History$=String$(1, 0)

' create path to db and open it
OSPathNetConstruct "", db.Server, db.FilePath, Path$
NSFDbOpen Path$, hDb&

' read the ACL into memory, and retrieve the history
NSFDbReadACL hDb&, hACL%
ACLGetHistory hACL%, hHistory%, nCount%

' process only if there are entries in the ACL history
If nCount% > 0 Then
nLoop%=0

' lock down the handle to the history
hLock=OSLockObject(hHistory%)

Do While nLoop% < nCount%
' extract history one character at a time using Win32 API call
CopyMemory History$, hLock&, 1

If History$ = Chr$(0) Then
' if we encounter a null character, there will be one following it
(e.g., LastEntry\0\0PrevEntry\0\0),
' so advance pointer two steps, copy current entry to array, and begin
work on next entry
nLoop%=nLoop% + 1
hLock& = hLock& + 2
Redim Preserve theList(nLoop%)
theList(nLoop%)=Hold$
Hold=""
Else
' advanced pointer one char at a time, and build a history entry
hLock& = hLock& + 1
Hold$=Hold$ + History$
End If
Loop

' release the lock on--and free--the history handle
OSUnlockObject(hHistory%)
OSMemFree hHistory%

' return the history as a Variant
GetACLHistory=theList
Else
GetACLHistory=False
End If

' free handles to ACL and db
OSMemFree hACL%
NSFDbClose hDb&
End Function
This was first published in November 2000

Dig deeper on Lotus Notes Domino Administration Tools

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.uk

Close