读取和捕获 ACL

Reading and capturing the ACL

我被要求编写一个应用程序,允许用户 select 数据库并让它读取 ACL(包括角色)并将其存储到文档中。我还没有找到任何方法让您扫描 ACL 并像那样捕获内容。

您可以通过Java中的数据库class访问数据库的ACL。有一个 getAcl() 方法。获得 ACL 后,您可以遍历所有条目。

每个 AclEntry 对象都有获取访问级别、角色等的方法

这是向您发送此信息的代码: 服务器:XYZ 文件名:e_drev\abc.nsf Replica-ID:41256E1B0019C95C 未设置强制一致的 ACL 管理服务器:None ACL 条目访问级别角色用户类型可以删除可以创建 -默认- 管理员访问权限 [配置] 未指定 是 是

Dim session 作为新的 NotesSession Dim nam 作为 NotesName
将数据库调暗为 NotesDatabase Dim maildoc As NotesDocument
Dim acl 作为 NotesACL 昏暗条目作为注释ACLEntry 将 entryName 变暗为字符串 昏暗级别作为字符串 昏暗的角色作为字符串 将 uType 调暗为字符串 将 rti 调暗为 NotesRichTextItem 将 rtnav 调暗为 NotesRichTextNavigator 将 rtt 调暗为 NotesRichTextTable

Set nam = session.CreateName(session.UserName)

Dim workspace As New NotesUIWorkspace
Dim askme As Variant

askme = workspace.Prompt("13","Mail me ACL and DB-info", "Select database to report on: ")
Set db = session.GetDatabase(askme(0), askme(1))
Set acl = db.ACL

Dim richStyle As NotesRichTextStyle 
Set richStyle = session.CreateRichTextStyle
richStyle.NotesFont = FONT_HELV
richStyle.FontSize = 9
richStyle.Bold = True

Dim plainStyle As NotesRichTextStyle    
Set plainStyle = session.CreateRichTextStyle
plainStyle.Bold = False

Set maildoc = New NotesDocument( db )

Set rti = maildoc.CreateRichTextItem("body")
Call rti.AppendText("Server: " + db.Server + Chr(13))
Call rti.AppendText("Filename: " + db.FilePath + Chr(13))
Call rti.AppendText("Replica-ID: " + db.ReplicaID + Chr(13))

If acl.UniformAccess Then
    Call rti.AppendText("Enforce consistent ACL is set" + Chr(13))
Else 
    Call rti.AppendText("Enforce consistent ACL is NOT set" + Chr(13))
End If

If acl.AdministrationServer <> "" Then
    Call rti.AppendText("Administration server: " + acl.AdministrationServer + Chr(13))
Else
    Call rti.AppendText("Administration server: None" + Chr(13))
End If

Call rti.AppendTable(1, 6)

Set rtnav = rti.CreateNavigator     
Call rtnav.FindFirstElement(RTELEM_TYPE_TABLE)
Set rtt = rtnav.GetElement  

Call rtnav.FindFirstElement(RTELEM_TYPE_TABLECELL)  

' 创建 table 个标题 调用 rti.AppendStyle(richStyle)

Call rti.BeginInsert(rtnav)
rti.AppendText("ACL Entry")
Call rti.EndInsert
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)

Call rti.BeginInsert(rtnav)
rti.AppendText("Access Level")
Call rti.EndInsert
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)

Call rti.BeginInsert(rtnav)
rti.AppendText("Roles(s)")
Call rti.EndInsert
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)

Call rti.BeginInsert(rtnav)
rti.AppendText("UserType")
Call rti.EndInsert
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)

Call rti.BeginInsert(rtnav)
rti.AppendText("Can delete")
Call rti.EndInsert
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)

Call rti.BeginInsert(rtnav)
rti.AppendText("Can create")
Call rti.EndInsert
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)

Set entry = acl.GetFirstEntry

While Not ( entry Is Nothing )
    entryName = entry.Name

    If ( entry.Level = ACLLEVEL_NOACCESS ) Then
        level = "No access"
    Elseif ( entry.Level = ACLLEVEL_DEPOSITOR ) Then
        level = "Depositor"
    Elseif ( entry.Level = ACLLEVEL_READER ) Then
        level = "Reader"
    Elseif ( entry.Level = ACLLEVEL_AUTHOR ) Then
        level = "Author"
    Elseif ( entry.Level = ACLLEVEL_EDITOR ) Then
        level = "Editor"
    Elseif ( entry.Level = ACLLEVEL_DESIGNER ) Then
        level = "Designer"
    Elseif ( entry.Level = ACLLEVEL_MANAGER ) Then
        level = "Manager access"
    End If          

    Forall role In entry.Roles

        If Isarray(entry.Roles) Then
            roles = roles & role & " "
        End If

    End Forall

    If ( entry.UserType = ACLTYPE_UNSPECIFIED ) Then
        uType = "Unspecified"
    Elseif ( entry.UserType = ACLTYPE_PERSON ) Then
        uType = "Person"
    Elseif ( entry.UserType = ACLTYPE_SERVER ) Then
        uType = "Server"
    Elseif ( entry.UserType = ACLTYPE_MIXED_GROUP ) Then
        uType = "Mixed group"
    Elseif ( entry.UserType = ACLTYPE_PERSON_GROUP ) Then
        uType = "Person group"
    Elseif ( entry.UserType = ACLTYPE_SERVER_GROUP ) Then
        uType = "Server group"
    End If

    Call rtt.AddRow(1)
    Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)

    Call rti.AppendStyle(plainStyle)    ' turn off bold 
    Call rti.BeginInsert(rtnav)
    rti.AppendText(entryName)
    Call rti.EndInsert
    Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)

    Call rti.BeginInsert(rtnav)
    rti.AppendText(level)
    Call rti.EndInsert
    Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)

    Call rti.BeginInsert(rtnav)
    rti.AppendText(roles)
    Call rti.EndInsert
    Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)

    'UserType
    Call rti.BeginInsert(rtnav)
    rti.AppendText(uType)
    Call rti.EndInsert
    Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)

    'CanDelete
    Call rti.BeginInsert(rtnav)
    If entry.CanDeleteDocuments Then
        rti.AppendText("Yes")   
    Else
        rti.AppendText("No")    
    End If
    Call rti.EndInsert
    Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)

    'CanCreate
    Call rti.BeginInsert(rtnav)
    If entry.CanCreateDocuments Then
        rti.AppendText("Yes")   
    Else
        rti.AppendText("No")    
    End If
    Call rti.EndInsert
    Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)

    Set entry = acl.GetnextEntry(entry)
    roles = ""

Wend    

maildoc.form="Memo" 
maildoc.subject="ACL and database info for " & db.Title
Call maildoc.Send( False, session.UserName) ' use current name for to address

Messagebox "An email has been sent to " &  nam.Abbreviated , 0 , "Action Complete"