GET ACL HISTORY CLASS

xiaoxiao2021-03-06  85

A customer of ours recently wanted to do an audit of all the ACL changes in all their databases. Luckily, we have an ACL History LotusScript class that is able to read the ACL History (go into the ACL of a database, then go to the Log tab). There is a new NotesDatabase property with Notes / Domino 6 called ACLActivityLog that should return this same information, but for those of you who need this information (the customer had not upgraded to Notes / Domino 6 yet) here's how you CAN GET IT IN AN R4 OR R5 Environment.

THIS Uses a Custom Class to make Things Easier. Custom Classes Go In THE

(Declarations) Area, So Create a new agent or script library and go osit

(Declarations) area. Add in this code:

Declare Private Function W32_NSFDbOpen Lib "nnotes" Alias ​​"NSFDbOpen" (Byval PathName As Lmbcs String, _hDB As Long) As IntegerDeclare Private Function W32_NSFDbReadACL Lib "nnotes" Alias ​​"NSFDbReadACL" (Byval hDB As Long, _hACL As Integer) As IntegerDeclare Private Function W32_ACLGetHistory Lib "nnotes" Alias ​​"ACLGetHistory" (Byval hACL As Integer, _hHistory As Integer, HistoryCount As Integer) As IntegerDeclare Private Function W32_NSFDbClose Lib "nnotes" Alias ​​"NSFDbClose" (Byval hDB As Integer) As IntegerDeclare Private Function W32_OSMemFree Lib "nnotes "Alias" OSMemFree "(Byval Handle As Integer) As IntegerDeclare Private Function W32_OSLockObject Lib" nnotes "Alias" OSLockObject "_ (Byval nHandle As Long) As LongDeclare Private Function W32_OSUnlockObject Lib" nnotes "Alias" OSUnlockObject "_ (Byval nHandle As Long ) AS INTEGERDECLARE PRIVATE SUB W32_RTLMOVEMORY LIB "kernel32" Alias ​​"RTLMoveMemory" (Byval Psource As Long, Byval Dwlength As long) CLAS s ACLHistory Private db As notesDatabase Public Sub new (inputDb As notesDatabase) Set Me.db = inputDb End Sub Public Function history As Variant Dim path As String Dim rc As Integer Dim hDb As Long Dim hLock As Long Dim hHistory As Integer Dim hACL As Integer Dim Ncount AS Integer Dim I as Integer Dim Char AS String Dim RetVal As Variant if Me.db.server = "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" DB.FILEPATH END IF RC =

W32_NSFDBOPEN (PATH, HDB) IF RC <> 0 THEN HISTORY = "" RETURN A VALUE THATORY = "RETURN A VALUE THATORY IS Not an Array In Any Error Situation EXIT FUNCTION End IF RC = W32_NSFDBREADACL (HDB, HACL) IF RC <> 0 THEN CALL W32_NSFDBCLOSE hDb) history = "" 'Return a value that is not an array in any error situation Exit Function End If rc = W32_ACLGetHistory (hACL, hHistory, nCount) If rc <> 0 Or nCount = 0 Then Call W32_NSFDbClose (hDb) history = "" 'Return a value that is not an array in any error situation Exit Function End If hLock = W32_OSLockObject (hHistory) Redim retVal (nCount-1) As String char = String $ (1,0)' Set up initially as character zero For the API CALL TO Properly Return Something For i = 0 To Ncount-1 Retval (i) = "" "" Call W32_RTLMOVEMEMORY (CARAR, HLOCK, 1) 'Read The first (or next) Character While CHAR = CHR $ (0)' There Are Two char 0's at the end of each entry - skip over the second one hLock = hLock 1 Call W32_RtlMoveMemory (char, hLock, 1) Wend While char <> Chr $ (0) 'extract history one character at a time using Win32 API call until we get a full word retVal (i) = retVal (i) & char hLock = hLock 1 Call W32_RtlMoveMemory (char, hLock, 1) Wend Next Call W32_OSUnlockObject (hHistory) Call W32_OSMemFree (hHistory) Call W32_OSMemFree (hACL) Call W32_NSFDbClose (HDB) History =

RETVAL END FUNCTION 'Ends The "History" Function End Class' Ends The "ACL History" Classthis One of Those "Black Box" Classes That You Don't really need to know how it it works. It uses the c API to grab the listory information and build an array of strings with the history. to use the custom class, you create a new ACLHistory object and pass in the database to be evaluated. Then you get the history property of the ACLHistory object and you can process this history to Print Out The History or Scan for Certain Criteria (Dates Or User Names).

For A Sample Agent to Verify The Custom Class, Here Is Some Code:

Sub Initialize Dim s As New NotesSession Dim db As NotesDatabase Dim acl As ACLHistory Dim history As Variant Dim i As Integer Dim msg As String Set db = s.CurrentDatabase Set acl = New ACLHistory (db) msg ​​= "" history = acl.history For i = lbound (history) to Ubound (History) MSG = MSG & ChR $ (10) & History (i) Next MsgBox "ACL History =" & MSG, 64, DB.TITLE & "ACL HISTORY" End Sub

......................

转载请注明原文地址:https://www.9cbs.com/read-107255.html

New Post(0)