I needed to find the people that belonged to a given lotus Notes group. It couldn’t be a simple lookup since other groups can and frequently are also members of a group, so it needed to be be recursive.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | Function expandGroupListMembers(GroupName) As Variant Dim session As New NotesSession Dim db As NotesDatabase Dim gView As NotesView Dim memberList As Variant Dim gDoc As NotesDocument Set db = session.CurrentDatabase Dim nab As New NotesDatabase(db.Server ,"names.nsf") ' this assumes that db is NOT running locally but is a server Set gView = nab.GetView("($VIMGroups)" ) Set gDoc = grpsView.GetDocumentByKey( GroupName , True ) If gDoc Is Nothing Then Exit Function 'could not find this GroupName in view so stop and return empty memberList = gDoc.GetItemValue( "Members" ) Forall member In memberList Dim subMemberList As Variant subMemberList = expandGroupListMembers(member) 'see if member is a group and if so get its members, recursively. If Not Isempty(subMemberList) Then 'member was a group, now add all its members to list If Isempty (expandGroupList) Then expandGroupListMembers= subMemberList Else expandGroupListMembers= AddArraysEval (expandGroupListMembers, subMemberList) End If Else 'member was not a group therefore assume is a person and add to list ' note it could be a server or something else If Isempty (expandGroupListMembers) Then expandGroupListMembers= member Else expandGroupListMembers= AddArraysEval (expandGroupListMembers, member) End If End If End Forall End Function Function AddArraysEval (a1 As Variant, a2 As Variant) As Variant 'from http://www.nsftools.com/tools/lsbook.htm '** add two arrays or scalar values using @Functions Dim session As New NotesSession Dim db As NotesDatabase Dim doc As NotesDocument Dim var As Variant Set db = session.CurrentDatabase Set doc = New NotesDocument(db) Call doc.ReplaceItemValue("a1", a1) Call doc.ReplaceItemValue("a2", a2) AddArraysEval = Evaluate("a1 : a2", doc) '** clean up the memory we used Set doc = Nothing Set db = Nothing End Function |
the AddArraysEval is from Julian Robichaux’s very handy LotusScript Book
Subscribe by RSS
Subscribe by Email
Follow Me on Twitter
my Del.icio.us Bookmarks
my Flickr Pictures




3 Comments
What about @UserNamesList?
@UserNamesList will give you Roles and Groups associated with the user in the ACL, but not all the names in a Group.
The code is looking for the function expandGroupList(). Is this just a typo or that function was left out?
Ian > typo! Should be fixed. sorry about that, and thanks for the catch.