Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2006-04-03
11
Medium Priority
?
323 Views
Last Modified: 2013-12-18
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
0
Comment
Question by:notesrookie
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 63

Expert Comment

by:SysExpert
ID: 16367158
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
 
LVL 63

Expert Comment

by:SysExpert
ID: 16367168
0
 
LVL 22

Accepted Solution

by:
mbonaci earned 2000 total points
ID: 16368553
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16369134
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
 

Author Comment

by:notesrookie
ID: 16372320
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
 

Author Comment

by:notesrookie
ID: 16372352
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
 

Author Comment

by:notesrookie
ID: 16372395
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
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16372895
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
 

Author Comment

by:notesrookie
ID: 16386389
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
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16389808
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
 

Author Comment

by:notesrookie
ID: 16392929
Hey ya sjef - I'll open a question just for you. Thanks.
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question