Subject: RE: NotesGroupManager ?
The NotesGroupManager doesn’t expose any methods for determining which groups – out of all of them – a particular person or group is a member of. However, you could write yourself a little subroutine.
Question is, what form should the output take? You expressed it as a string, but the hierarchy of group inclusion can get sort of complex, making this difficult to read. Ron is a member of Zam, which is a member of Grod and Pinkie, which is a member of Treacle, which is a member of Scoop and Fantod, Hoops, which is a member of Spaghetti, and Umbrella.
It might be better to shoot for a graphical or list-indented display of the results, e.g.:
Ron
You could create such output using a recursive routine that scans the list of groups at each level looking for a particular name. Depending how many of these things you want to do in a single execution, though, it might be more efficient to create a reverse lookup list in memory, indexed by person/group name, that lists the groups of which that person or group is a member.
Here’s how you might do the former version – you can try it out in the group manager sample database with the name James Hook/BadGuys/Neverland:
Option Public
Option Declare
Use “GroupManager”
Const NEWLINE = {
}
Sub Initialize
Dim session As New NotesSession
Dim dbCurrent As NotesDatabase
Dim gman As New NotesGroupManager(False)
Dim group As NotesGroup
Set dbCurrent = session.CurrentDatabase
Call gman.LoadAddressBook(dbCurrent)
Call gman.LoadAllGroups
Dim cache As Variant
cache = gman.CachedGroups ' more efficient to request this only once.
Dim strInput As String, strResult As String
strInput = Inputbox("What name do you want to look up?")
If strInput <> "" Then
strResult = GroupHierarchyOf(cache, strInput)
Msgbox strResult, 0, "Your answer"
End If
End Sub
Function GroupHierarchyOf(cache As Variant, strWho As String) As String
GroupHierarchyOf = strWho
Forall grp In cache
If grp.IsMember(strWho) Then
GroupHierarchyOf = GroupHierarchyOf & NEWLINE _
& Indent(GroupHierarchyOf(cache, grp.Name))
End If
End Forall
End Function
Function Indent(strIn) As String
Indent = " - " & Replace(strIn, NEWLINE, NEWLINE & " - ")
End Function
Note that this doesn’t find wildcards or variants, e.g. groups that contain James Hook as a common name, or */Neverland. You would have to do that yourself and merge the results.