Manage Learn to apply best practices and optimize your operations.

Script To Extract All Group Associations For An User

Administrators always need to check database ACL when users reported that they
have access problems. Sometimes, ACL is defined by groups and the worst case
is that group is defined within another group.

The following function will extract all the associated groups for a specified
user. This will make the analysis faster.
This example is the Click event for a hotspot button in a form:-

Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim doc As NotesDocument
Set doc = ws.CurrentDocument.Document
Dim saGroups () As String
If GetUserGroupAssociations (doc.User(0), _
saGroups)=False Then
Msgbox "This guy is not in any groups !"
doc.Groups = saGroups
End If
End Sub

Function GetUserGroupAssociations (strCommonUserName As String, asGroups () As
Dim session As New NotesSession
Dim db As NotesDatabase
Dim docCollection As NotesDocumentCollection
Dim doc As NotesDocument
Dim iCount As Integer
Dim iDuplicate As Integer
Dim x As Integer
Dim y As Integer
Dim dateTime As New NotesDateTime ("1/1/1971")
Set db = session.CurrentDatabase
Set db_PAB = session.GetDatabase(db.Server, "Names.nsf")

GetUserGroupAssociations = True

'Check for members in group containing the Notes name
searchFormula$ = _
"Form = ""Group"" & @Contains(@Name([CN];Members);""" + _
strCommonUserName + """)"
Set docCollection = db_PAB.Search(searchFormula$, dateTime, 0)
If docCollection.Count <> 0 Then
For iCount=1 To docCollection.Count
Set doc = docCollection.GetNthDocument(iCount)
Redim Preserve asGroups (0 To iCount-1)
asGroups(iCount-1) = doc.ListName(0)
iTerminate = iCount -1
GetUserGroupAssociations = False
Exit Function
End If

'Check for initially collected groups in other groups
For x=0 To iTerminate
searchFormula$ = _
"Form = ""Group"" & @Contains(@Name([CN];Members);""" + _
asGroups(x) + """)"
Set docCollection = db_PAB.Search(searchFormula$, dateTime, 0)
If docCollection.Count <> 0 Then
For y=1 To docCollection.Count
Set doc = docCollection.GetNthDocument(y)
'Check for duplicate groups
Forall group In asGroups
If group = doc.ListName(0) Then
End If
End Forall
If iDuplicate <> 1 Then
Redim Preserve asGroups (0 To iCount-1)
asGroups(iCount-1) =
iCount = iCount + 1
End If
End If
End Function

Dig Deeper on Domino Resources - Part 4

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...