Jul 7, 2015, 3:01 PM
9 Posts
topic has been resolvedResolved

Agent to read ACL and copy it in to new document

  • Category: Other Domino Designer Tooling
  • Platform: All
  • Release: 9.0.1
  • Role: Administrator,Developer
  • Tags: agent,xpage,form,document,acl,roles
  • Replies: 0

Hi guys, I am trying to create an agent that runs every hour and checks for changes in the ACL...basically I have created an xpages and I want to show who has access and what roles on it...I thought the best way to do this was to create an agent that reads the ACL and stores it in a document.

I am having trouble with the agent (I am new to lotus script) and was wondering if anyone can help out on figure how to write the right agent for this task.

 

Agent:


Option Public


Option Declare

Dim s As NotesSession
    Dim db As NotesDatabase
    Dim view As NotesView
    Dim dc As NotesDocumentCollection
    Dim maindoc As NotesDocument
    Dim localdoc As NotesDocument
    Dim rtItem As NotesRichTextItem
    Dim srtItem As NotesRichTextItem
    Dim item As NotesItem
    Dim NotesACL As NotesACL
    Dim NotesACLEntry As NotesACLEntry
    
        
Sub Initialize
    
    Set s = New NotesSession
    
    Set db = s.CurrentDatabase
    Set NotesACL = db.ACL
    Dim rtItem As NotesRichTextItem
    Dim srtItem As NotesRichTextItem
    Dim NotesACLEntry As NotesACLEntry
    Dim AssignedRole As String
    
    Set maindoc = db.CreateDocument
    maindoc.form = "Admins"
    Set NotesACLEntry =  NotesACL.Getfirstentry()
    If NotesACLEntry.Isperson Then
        AssignedRole = Implode(NotesACLEntry.Roles, "  ")
        Call srtItem.Appendtext(NotesACLEntry.name + " Roles:  " + AssignedRole)
        Call srtItem.AddNewLine(1)
    End If
    Set NotesACLEntry = NotesACL.GetNextEntry(NotesACLEntry)
    Do While Not NotesACLEntry Is Nothing
        If NotesACLEntry.Isperson Then
            AssignedRole = Implode(NotesACLEntry.Roles, "  ")
            Call srtItem.Appendtext(NotesACLEntry.name + " Roles:  " + AssignedRole)
            Set srtItem  = rtItem.CopyItemToDocument( maindoc, "Administrator" )
            Call srtItem.AddNewLine(1)
        End If
        Set NotesACLEntry = NotesACL.GetNextEntry(NotesACLEntry)
    Loop
    
    End Sub

 

Thank you!