读取和捕获ACL

时间:2017-11-17 15:34:45

标签: xpages acl

我被要求编写一个应用程序,允许用户选择数据库并让它读取并将ACL(包括角色)存储到文档中。我无法找到任何让你扫描ACL并捕获这些内容的方法。

2 个答案:

答案 0 :(得分:3)

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

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

答案 1 :(得分:2)

以下是向您发送此信息的代码: 服务器:XYZ 文件名:e_drev \ abc.nsf 副本ID:41256E1B0019C95C 未设置强制一致的ACL 管理服务器:无 ACL条目访问级别角色UserType可以删除可以创建 -Default-管理员访问[配置]未指定是是

Dim session As New NotesSession     Dim nam作为NotesName
    Dim db作为NotesDatabase     Dim maildoc作为NotesDocument
    Dim acl作为NotesACL     昏暗的条目作为NotesACLEntry     Dim entryName As String     昏暗级别为字符串     昏暗角色As String     Dim uType As String     Dim rti作为NotesRichTextItem     Dim rtnav作为NotesRichTextNavigator     Dim 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)  

'创建表格标题     调用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"