Lotus Notes FAQ Visit Our Sponsor!

How do you make a list of all groups a person is in?

Create view in the NAB with a selection formula of "Select (Form = "Group").
Add the field 'Members' in first column.
In the propeties box for the first column, select sorting type 'categorized' and select 'show multiple values as separate entries'.
In the second column, put the field 'ListName'.

This is not recursive, so it won't show a person in a nested group.

An alternative way (from chowell@epd.renold.com) is to:
1) Load the Name & Address Book D/Base and select the "Groups" view
2) Enable the Search Bar (View, Search Bar) - the NAB has to be full text indexed
3) Key in the name of the person you are seeking - the Groups of which they are a member are identified in the view
or use the search string:

  FIELD Members contains "username or groupname" 

so you avoid false hits on the ListOwner and LocalAdmin fields.

And another way using the Notes API from agorlenko@manu.com but this only works on R5+:

Declare Function NSFBuildNamesList Lib "NNOTES" Alias "NSFBuildNamesList" _
( Byval S As String, Byval F As Long, hNL As Long) As Integer

Declare Function OSLockObject Lib "NNOTES" Alias "OSLockObject" _
( Byval H As Long) As Long

Declare Sub OSUnlockObject Lib "NNOTES" Alias "OSUnlockObject" _
( Byval H As Long)

Declare Function OSMemFree Lib "NNOTES" Alias "OSMemFree" _
( Byval Handle As Long) As Integer

Declare Function ReadInteger Lib "MSVCRT" Alias "memcpy" _
( N As Integer, Byval P As Long, Byval B As Long) As Long

Declare Function ReadString Lib "MSVCRT" Alias "memcpy" _
( Byval S As String, Byval P As Long, Byval B As Long) As Long

Sub Initialize
        Dim session As New NotesSession
        Dim x As String
        Dim m As String
        Dim p As Integer
        Dim I As Integer
        Dim n As Integer
        Dim hNL As Long
        Dim GroupCount List As Integer
        Dim a As String
        Dim abook As NotesDatabase
        Dim aview As NotesView
        Dim doc As NotesDocument
        On Error Goto oops
        Set abook = session.GetDatabase("", "names.nsf")
        Set aview = abook.GetView("People")
        Set doc = aview.GetFirstDocument
        Do Until doc Is Nothing
                a = doc.FullName(0) 
         ' Get Names List handle (fails on R4)
                'On Error Resume Next
                NSFBuildNamesList a$, 0, hNL
                'On Error Goto 0
                If hNL = 0 Then
                        Print "Failed"
                        Exit Sub
                End If
  ' Get memory pointer
                Dim pNL As Long
                pNL = OSLockObject(hNL)
  ' Get number of entries, skip to first entry
                ReadInteger n%, pNL, 2
                pNL = pNL + 14
  ' Read the entries
                For i% = 1 To n%
                        x$ = String$(256, " ")
                        ReadString x$, pNL, 256
                        p% = Instr(x$, Chr$(0))
                        pNL = pNL + p%
                        If Not p% = 0 Then x$ = Left$(x$, p% - 1)

  ' each group is listed in x$ in this loop

  ' Discard the Names List
                OSUnlockObject hNL
                OSMemFree hNL
                'Exit Do
                Set doc=aview.GetNextDocument(doc)

Exit Sub

Applies to Notes Versions: 3 4 4.5 4.6 5 6 6.5 7
Last Modified: July 19, 2005