Get ACL History Class

原创 2004年10月12日 21:33:00
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 hadn't 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 into the (Declarations) area, so create a new agent or script library and go into the (Declarations) area. Add in this code:

Declare Private Function W32_NSFDbOpen Lib "nnotes" Alias "NSFDbOpen" (Byval PathName As Lmbcs String, _
hDB As Long) As Integer
Declare Private Function W32_NSFDbReadACL Lib "nnotes" Alias "NSFDbReadACL" (Byval hDB As Long, _
hACL As Integer) As Integer
Declare Private Function W32_ACLGetHistory Lib "nnotes" Alias "ACLGetHistory" (Byval hACL As Integer, _
hHistory As Integer, HistoryCount As Integer) As Integer
Declare Private Function W32_NSFDbClose Lib "nnotes" Alias "NSFDbClose" (Byval hDB As Integer) As Integer
Declare Private Function W32_OSMemFree Lib "nnotes" Alias "OSMemFree" (Byval Handle As Integer) As Integer
Declare Private Function W32_OSLockObject Lib "nnotes" Alias "OSLockObject" _
(Byval nHandle As Long) As Long
Declare Private Function W32_OSUnlockObject Lib "nnotes" Alias "OSUnlockObject" _
(Byval nHandle As Long) As Integer
Declare Private Sub W32_RtlMoveMemory Lib "kernel32" Alias "RtlMoveMemory" (Byval pDest As Lmbcs String, _
Byval pSource As Long, Byval dwLength As Long)

Class 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 = "" Then
         path = Me.db.filePath
         path = Me.db.server & "!!" & Me.db.filePath
      End If
      rc = W32_NSFDbOpen(path, hDb)
      If rc <> 0 Then
         history = ""    ' Return a value that 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(char, 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)
         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)
      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" class

This is one of those "black box" classes that you don't really need to know how 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)
   Msgbox "ACL History = " & msg, 64, db.title & " ACL History"
End Sub

This agent just builds a message box containing the entire history so you can verify the code.


history对象 来自《JavaScript 标准参考教程(alpha)》,by 阮一峰 目录 概述 history.pushState() history.repla...
  • gjl8685941
  • gjl8685941
  • 2017年12月25日 11:06
  • 133

使用 acl_cpp 库中的 http_request 类实现一个 HTTP 客户端请求的例子

之前写过几篇如何使用 acl 库来实现 HTTP 客户端的例子都是基于 C 语言(使用 acl 较为底层的 HTTP 协议库写 HTTP 下载客户端举例, 使用 acl 库开发一个 HTTP 下载客户...
  • zsxxsz
  • zsxxsz
  • 2014年09月09日 09:55
  • 504


1、HAProxy简介 HAProxy 是一款高性能TCP/HTTP 反向代理负载均衡服务器,具有如下功能: 根据静态分配的cookies完成HTTP请求转发 在多个服务器间实现...
  • yujin2010good
  • yujin2010good
  • 2017年07月14日 18:46
  • 440


Ajax保留浏览器历史的解决方案 ul class="menu"> li>a href="/home/index#page=1">page1a>li> li>a href="/home/in...
  • shuawanxiao
  • shuawanxiao
  • 2015年01月11日 17:33
  • 20428


HDFS的文件ACL(Access Control Lists),类似于POSIX ACL(Linux使用ACL来管理文件权限)。 首先参数上要开启基本权限和访问控制列表功能,在CDH 5.2中,默认...
  • qq_14918243
  • qq_14918243
  • 2017年04月27日 14:35
  • 470

使用 acl_cpp 库编写多线程程序

在 《利用ACL库开发高并发半驻留式线程池程序》中介绍了如何使用 C 版本的 acl 线程库编写多线程程序,本文将会介绍如何使用 C++ 版本的 acl 线程库编写多线程程序,虽然 C++ 版 acl...
  • zsxxsz
  • zsxxsz
  • 2014年09月09日 09:54
  • 1025

es6 javascript的class类中的 get和set

与 ES5 一样, 在 Class 内部可以使用get和set关键字, 对某个属性设置存值函数和取值函数, 拦截该属性的存取行为。class MyClass { constructor() { ...
  • qq_30100043
  • qq_30100043
  • 2016年12月09日 18:32
  • 8829

Linux具体权限规划之ACL(Access Control List)

ACL机制涉及两条命令:setfacl 、getfacl ACL来源 owner,group,othre搭配的三种权限rwx中,没办法针对单一用户或者某个组。 ACL可以...
  • Jammg
  • Jammg
  • 2016年03月30日 18:56
  • 732

This is class com.sumiplus.servlet.RedirectServlet, using the GET method

This is class com.sumiplus.servlet.RedirectServlet, using the GET method 出现这个这个问题,是由于servlet没有被编译...
  • wconvey
  • wconvey
  • 2013年04月02日 20:25
  • 2939

spring security:访问控制列表来保护领域对象

之前提到的安全保护和权限控制都是只针对 URL 或是方法调用,只对一类对象起作用。而在有些情况下,不同领域对象实体所要求的权限控制是不同的。以第一类示例应用来说,系统中有报表这一类实体。由于报表的特殊...
  • dongzi87
  • dongzi87
  • 2015年08月31日 23:16
  • 1981
您举报文章:Get ACL History Class