Populating ACL information in a table within a rich text field in a document

Most learned experts,

I am trying to write an agent that will generate a table in the body of a document. I know for sure that there will be 7 columns for the ACL information that I am looking for and am gathering the information within a 2D string array. I'm getting a subscript out of range error. My code is below. Am using v5.0.12. If someone could straighten me out, it would be greatly appreciated. And if there is a simpler way to execute this that would be appreciated as well. Many thanks.

Dim db As New NotesDatabase( "notes_server", "thisdb.nsf" )
      Dim doc As NotesDocument
      Dim rtitem As NotesRichTextItem
      Dim acl As NotesACL
      Dim aclentry As NotesACLEntry
      Dim usrname As String, usertype As String, level As String, createdoc As String, deletedoc As String, repldoc As String
      Dim anyroles As String, stmt As String
      Dim i As Integer      'row count
      Dim c As Integer      'column count
      
      Set doc = New NotesDocument(db)
      doc.Form = "Main Topic"
      doc.From = "Current User"
      doc.Subject = "Current database ACL"
      
      Set rtitem = New NotesRichTextItem( doc, "Body" )
      Set acl = db.ACL
      Set aclentry = acl.GetFirstEntry
      i = 0
      Redim myTable(i, 6) As String
      
      While Not (aclentry Is Nothing)      
            
            usrname = Cstr(aclentry.Name)
            c = 0
            myTable(i, c) = usrname
            
            Select Case aclentry.UserType
            Case 0: usertype = "Unspecified"
            Case 1: usertype = "Person"
            Case 2: usertype = "Server"
            Case 3: usertype = "Mix group"
            Case 4: usertype = "Person group"
            Case 5: usertype = "Server group"
            End Select
            c = c + 1
            myTable(i, c) = usertype
            
            Select Case aclentry.Level
            Case 0: level = "No Access"
            Case 1: level = "Depositor"
            Case 2: level = "Reader"
            Case 3: level = "Author"
            Case 4: level = "Editor"
            Case 5: level = "Designer"
            Case 6: level = "Manager"
            End Select
            c = c + 1
            myTable(i, c) = level
            
            If aclentry.CanCreateDocuments Then
                  createdoc = "Yes"
            Else
                  createdoc="No"
            End If
            c = c + 1
            myTable(i, c) = createdoc
            
            If aclentry.CanDeleteDocuments Then
                  deletedoc = "Yes"
            Else
                  deletedoc="No"
            End If
            c = c + 1
            myTable(i, c) = deletedoc
            
            If aclentry.CanReplicateOrCopyDocuments Then
                  repldoc = "Yes"
            Else
                  repldoc="No"
            End If
            c = c + 1
            myTable(i, c) = repldoc
            
            Forall r In aclentry.Roles
                  If r = "" Then
                        anyroles = ""
                  Else
                        anyroles = anyrole & ", " & r      
                  End If
                  c = c + 1
                  myTable(i, c) = anyroles
            End Forall
            
            i = i + 1
            Redim Preserve myTable(i, 6) As String  <-- this iis where I am encountering the error
            Set aclEntry = acl.GetNextEntry( aclentry )
            
      Wend
      
      Call rtitem.AppendTable(i, c)
      Dim rtnav As NotesRichTextNavigator
      Set rtnav = rtitem.CreateNavigator
      Call rtnav.FindFirstElement(RTELEM_TYPE_TABLECELL)
      For iRow% = 1 To i Step 1
            For iColumn% = 1 To c Step 1
                  Call rtitem.BeginInsert(rtnav)
                  Call rtitem.AppendText(myTable(i,c))
                  Call rtitem.EndInsert
                  Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
            Next
      Next
      
      Print "Done."
      Call doc.Save(True, True)
      Dim ws As New NotesUIWorkspace
      Call ws.ViewRefresh
notesrookieAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SysExpertCommented:
Why not use some free tools to get this info.

See LDD
http://www-10.lotus.com/ldd/sandbox.nsf?OpenDatabase
Search for ACL

there are a couple of good ones including one from IBM that allow export to Excel.

I hope this helps !
0
SysExpertCommented:
0
mbonaciCommented:
Hi notesrookie,
The reason why you get the error is:

If you do include Preserve in a ReDim statement, the only bound that LotusScript lets you change (by incrementing) is the upper bound of the last array dimension.
You cannot change the number of dimensions of an array or the data type of its elements with a ReDim statement.

So I suggest you to make the first dymension constant and increment the second one.
Like this:



Sub Click(Source As Button)
   
    Dim db As New NotesDatabase( "notes_server", "thisdb.nsf" )
    Dim doc As NotesDocument
    Dim rtitem As NotesRichTextItem
    Dim acl As NotesACL
    Dim aclentry As NotesACLEntry
    Dim usrname As String, usertype As String, level As String, createdoc As String, deletedoc As String, repldoc As String
    Dim anyroles As String, stmt As String
    Dim iRow As Integer, iColumn As Integer
    Dim i As Integer     'row count
    Dim c As Integer     'column count
    Dim myTable() As String
   
    Set doc = New NotesDocument(db)
    doc.Form = "Main Topic"
    doc.From = "Current User"
    doc.Subject = "Current database ACL"
   
    Set rtitem = New NotesRichTextItem( doc, "Body" )
    Set acl = db.ACL
    Set aclentry = acl.GetFirstEntry
    i = 0
    Redim myTable(6, i) As String
   
    While Not (aclentry Is Nothing)    
       
        usrname = Cstr(aclentry.Name)
        c = 0
        myTable(c, i) = usrname
       
        Select Case aclentry.UserType
        Case 0: usertype = "Unspecified"
        Case 1: usertype = "Person"
        Case 2: usertype = "Server"
        Case 3: usertype = "Mix group"
        Case 4: usertype = "Person group"
        Case 5: usertype = "Server group"
        End Select
        c = c + 1
        myTable(c,i) = usertype
       
        Select Case aclentry.Level
        Case 0: level = "No Access"
        Case 1: level = "Depositor"
        Case 2: level = "Reader"
        Case 3: level = "Author"
        Case 4: level = "Editor"
        Case 5: level = "Designer"
        Case 6: level = "Manager"
        End Select
        c = c + 1
        myTable(c,i) = level
       
        If aclentry.CanCreateDocuments Then
            createdoc = "Yes"
        Else
            createdoc="No"
        End If
        c = c + 1
        myTable(c, i) = createdoc
       
        If aclentry.CanDeleteDocuments Then
            deletedoc = "Yes"
        Else
            deletedoc="No"
        End If
        c = c + 1
        myTable(c, i) = deletedoc
       
        If aclentry.CanReplicateOrCopyDocuments Then
            repldoc = "Yes"
        Else
            repldoc="No"
        End If
        c = c + 1
        myTable(c, i) = repldoc
       
        Forall r In aclentry.Roles
            If r = "" Then
                anyroles = ""
            Else
                anyroles = anyroles & ", " & r
            End If
            c = c + 1
            myTable(c, i) = anyroles
        End Forall
       
        i = i + 1
        Redim Preserve myTable(6, i) As String  '<-- this iis where I am encountering the error
        Set aclEntry = acl.GetNextEntry( aclentry )
       
    Wend
   
    Call rtitem.AppendTable(c, i)
    Dim rtnav As NotesRichTextNavigator
    Set rtnav = rtitem.CreateNavigator
    Call rtnav.FindFirstElement(RTELEM_TYPE_TABLECELL)
   
    For iRow% = 0 To c - 1
       
        For iColumn% = 0 To i - 1
           
            Call rtitem.BeginInsert(rtnav)
            Call rtitem.AppendText(myTable(iRow, iColumn))            
            Call rtitem.EndInsert            
            Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
        Next
    Next
   
    Print "Done."
    Call doc.Save(True, True)
    Dim ws As New NotesUIWorkspace
    Call ws.ViewRefresh
End Sub



Hope this helps,
Marko
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Sjef BosmanGroupware ConsultantCommented:
I think a 1D-array would be enough. Why you need the column number I don't understand. You can create one string, where all values are separated by commas. If need be, you can split that string in a later stage using
    Split(myTable(i), ",")

Furthermore, why do you need the array? To separate information gathering and generating output? Then I suggest to do all in one go, you create separate Subs for both functionalities. If need be, you use two Classes for that purpose.
0
notesrookieAuthor Commented:
sjef - I am working, unfortunately, in v5.0.12 and will not be able to take advantage of the Split function. I thought that using an array would be a neat way to collect the information and then display it in a quick table in a document. Not sure what you meant by "do it all in one go". Please elaborate. Thanks.
0
notesrookieAuthor Commented:
Marko - The solution did get me past the "subscript out of range" line. However, there are 15 ACL entries in the database with 7 related acl items. Currently the table creation portion of it is creating a 15 x 7 table. I'd like a 7 x 15 table created with the data populating it accordingly. Any ideas? Thanks.
0
notesrookieAuthor Commented:
Marko - Thanks. I got it. I switched the irow and icolumn statements. And since you were spot on with your answer, i'll award you the points.
0
Sjef BosmanGroupware ConsultantCommented:
Okay, there's no split, but you could write one yourself... There is one in EE already somewhere, but you don't need it anymore :(
0
notesrookieAuthor Commented:
Acutally sjef - I'm glad you mentioned it. I don't know when I'll be upgrading to R6 so I'll look it up. As always I appreciate receiving comments.
0
Sjef BosmanGroupware ConsultantCommented:
I'm in a generous mood...

Function MySplit(Byval r As String, s As String) As Variant ' don't call it Split!
    Dim i As Integer
    Dim v As Variant
    Dim n As Integer

    Redim v(0)
    i= Instr(r,s)
    Do While i>0
        Redim Preserve v(n)
        v(n)= Left(r,i-1)
        r= Mid(r,i+Len(s))
        i= Instr(r,s)
        n= n+1
    Loop
    Redim Preserve v(n)
    v(n)= r
    MySplit= v
End Function
0
notesrookieAuthor Commented:
Hey ya sjef - I'll open a question just for you. Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.