Manage Learn to apply best practices and optimize your operations.

Finding All Of A User's Notes Acl Identities

Here's a way for Developers and Administrators to find all of the Notes ACL
identities for a user. This consists of the person's user name and all the
person's group memberships, even if the groups are nested.

The Notes R4.64 Help Database has two documents that discuss Groups and the
ability to nest Groups within each other. One document states that Groups can
be nested up to 6 levels, but another document states that Groups can be nested
with no limit. My testing proved that the nesting can go well beyond 6
levels! I can not verify that their is no limit to the nesting. This agent
will find all nested groups up to about 255 levels of nesting. If the nesting
goes beyond 255 levels, you will likely get an "Out of stack space" Windows

I use this technique in the Postopen event (Make the Initialize event a
subroutine in the Database Postopen script) of database to put a list of the
current user's memberships into a Profile document field. I then can hide or
show the Edit buttons, for example, by group membership, etc.

I also put an Action button in my People view in the Name & Address Book to
quickly get any highlighted persons Group memberships that has this formula:

The Initialize Event then needs to be modified to:
'Make sure we can open the name and address book
'We are currently in the Address Book, so set NAB to thisDb
'flag = NAB.Open(thisDb.Server, "names.nsf")
'If Not flag Then Exit Sub

Set NAB = thisDb
Set ServerAccess = NAB.GetView("($ServerAccess)")

Set profileDoc = thisDb.GetProfileDocument( "UserProfile" , sess.UserName)
Redim WhoAmI(0)
WhoAmI(0) = profileDoc.PersonName(0)
(Options) Event:
Option Public
Option Explicit

(Declarations) Event:
Dim ServerAccess As NotesView
Dim WhoAmI() As String
Dim WhoAmIcount As Integer

Initialize Event:
Sub Initialize
Dim sess As New NotesSession
Dim thisDb As NotesDatabase
Dim NAB As New NotesDatabase("","")
WhoAmIcount = -1
Dim flag As Variant
Dim keyArray(0) As String
Dim Msg As String
Dim count As Integer

Set thisDb = sess.CurrentDatabase

'Make sure we can open the name and address book
flag = NAB.Open(thisDb.Server, "names.nsf")
If Not flag Then Exit Sub

'This is the hidden view that lists all people and groups and the groups
they belong to
Set ServerAccess = NAB.GetView("($ServerAccess)")

'The first tiem in the list of Who I Am is my user name
keyArray(0) = sess.UserName
Redim WhoAmI(0)
WhoAmI(0) = sess.UserName
WhoAmIcount = 0

'This subroutine will find all of the groups that I am a member of and
also all of the nested groups
Call GetListNames(keyArray)

Msg = Msg & WhoAmI(0)
If WhoAmIcount > 0 Then
For count = 1 To WhoAmIcount
Msg = Msg & Chr$(13) & Chr$ (10) & WhoAmI(count)
End If

Msgbox Msg, , "Who Am I"
End Sub

GetListNames SubRoutine:
Sub GetListNames(keyArray() As String)
Dim doc As NotesDocument
Dim coll As NotesDocumentCollection
Dim count As Integer
Dim thisListName As String

Set coll = ServerAccess.GetAllDocumentsByKey(keyArray, True)
Set doc = coll.GetFirstDocument

While Not (doc Is Nothing)
thisListName = doc.ListName(0)
'Here we need to check to see if we already have this name in the
list in order to trap any circular references.
For count = 0 To Ubound(WhoAmI)
If thisListName = WhoAmI(count) Then Exit Sub
WhoAmIcount = WhoAmIcount + 1
Redim Preserve WhoAmI(WhoAmIcount)
WhoAmI(WhoAmIcount) = thisListName
keyArray(0) = doc.ListName(0)

'Call this subroutine again (recursively) to get the ListNames for
this ListName
Call GetListNames(keyArray)
Set doc = coll.GetNextDocument(doc)
End Sub

Dig Deeper on Domino Resources - Part 6

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...