Sub Initialize '============================================== ' Example of how to use GetGroupMembers '============================================== Dim session As New NotesSession Dim dbNAB As NotesDatabase Set dbNAB = session.AddressBooks(1) Print "number of nabs is" + Cstr(Ubound(session.AddressBooks)) Print "title is " + dbNAB.Title Print "Filepath is " + dbNAB.FilePath Print "Server is " + dbNaB.Server Dim strGroupName As String strGroupName = "LocalDomainAdmins" Dim strGroupMembersArr As Variant strGroupMembersArr = GetGroupMembers(strGroupName, dbNAB) Dim strGroupMembers As String Forall aName In strGroupMembersArr strGroupMembers = strGroupMembers + aName + ", " End Forall Print "Group members of " strGroupName " are " + strGroupMembers End Sub '============================================= ' Function GetGroupMembers '============================================= Function GetGroupMembers(strGroupName As String, dbNAB As NotesDatabase ) As Variant ' get Groupmembers is a standard group explode function designed to retrieve all users and users ' within nested groups and return an array of user names Dim session As New notesSession Dim nmUser As notesName Dim docGroup As notesDocument Dim docGroupMember As notesDocument Dim nmServer As notesName Dim vGroupList() As Variant Dim vGroupList2 As Variant Dim vwPerson As notesView Set nmServer = New notesName(Session.CurrentDatabase.Server) Redim vGroupList(0) As Variant If dbNAB Is Nothing Then 'Set DBNAB = GetAddressBook() End If Dim vwGroup As NotesView If dbNAB.IsOpen = False Then Call dbNAB.Open(dbNAB.Server, dbNAB.FilePath) End If If dbNAB.IsOpen Then If vwGroup Is Nothing Then Set vwGroup = dbNAB.getView("($VIMGroups)") End If Set docGroup = vwGroup.getDocumentByKey(strGroupName) If Not docGroup Is Nothing Then ' for each groupMember in members Forall groupMember In docGroup.Members If Trim(groupMember) <> "" Then ' if the group member is not a sub-group Set nmUser = New notesName(groupMember) Set docGroupMember = vwGroup.GetDocumentByKey(Trim(nmUser.Abbreviated)) If docGroupMember Is Nothing Then ' append it to the end of the list Call AddToArray(vGroupList, groupMember) Else ' ***** Recursive Call ***** vGroupList2 = GetGroupMembers(groupMember, dbNAB) ' *************************** ' add any recursed group names into the groupNames Forall groupMember2 In vGroupList2 Call AddToArray(vGroupList, Cstr(groupMember2)) End Forall End If End If End Forall End If Else Error 1000, "The Address book cannot be opened " + dbNAB.filepath End If GetGroupMembers = vGroupList End Function ' GetGroupMembers '============================================= ' Sub AddToArray '============================================= Sub AddToArray( iArray As Variant, newValue As String ) On Error Goto HandleError If Isempty(iArray) Then Redim iArray(0) As String End If If ( Ubound(iArray) = Lbound(iArray) ) And iArray(Ubound(iArray)) = "" Then ' raises error 200 if not initialized ' if we are a new array with nothing in it then do not increase size IsInitialized: iArray(Lbound(iArray)) = newValue Else Dim newSize As Integer newSize = Ubound(iArray)+1 Redim Preserve iArray(newSize) iArray(newSize) = newValue 'AddToArray = iArray End If Exit Sub HandleError: If Err = 200 Then ' uninitialized dynamic array '( it's actually an array, but does not have a single value in it Redim iArray( 0 To 0 ) Resume IsInitialized Else Print Err & " " & Error Error Err, Error Exit Sub End If End Sub ' add to array