Do you know a function which returns a list of groups and nested groups in which a user is. I need a function like UserGroupNameList property but with a parameter username.
There is a function like that used in the ACL which returns all groups from the username
Subject: Groups and nested groups from an userID or username
If you’re only interested in the group names, try this ->.dgg
Subject: RE: Groups and nested groups from an userID or username
Contrary to your response, I have the UserName and I want the groups in which the user is.
Subject: RE: Groups and nested groups from an userID or username
I misunderstood the problem. Below is a brute-force approach I wrote some time ago. We have around a thousand users with a couple of hundred groups and it performs ok (not great, just ok). There may be a more efficient approach, but this does work. There’s also a C function – NSFBuildNamesList – but I believe it determines group membership by way of the local NAB (vs the Public NAB) which is probably not what you want.
To use the function, pass a handle to the Public NAB and the name of the person (or group) you’re interested in. If you’re looking for a person, the name should be passed in its canonical form. The function returns an unsorted, non-unique array so the array will need to be cleaned up by the calling module with a call to ArrayUnique, then its contents can then be sorted as needed.
dgg
Function findGroupMembership(pndbNAB As NotesDatabase, pstrName As String) As Variant
On Error Goto errorHandler
Dim dclxn As NotesDocumentCollection
Dim doc As NotesDocument
Dim i As Integer
Dim intCount As Integer
Dim strGroupName As String
Dim varGroups As Variant
Dim varChildGroups As Variant
Set dclxn = pndbNAB.Search({Type = "Group" & GroupType != "3" & @IsMember("} & Ucase(pstrName$) & {"; @UpperCase(Members))}, Nothing, 0)
Set doc = dclxn.GetFirstDocument()
If doc Is Nothing Then
Goto thisExit
End If
strGroupName$ = doc.GetItemValue("ListName")(0)
varGroups = Split(strGroupName$, "{:}")
intCount% = dclxn.Count
For i = 1 To intCount%
varChildGroups = findGroupMembership(pndbNAB, strGroupName$)
If Isarray(varChildGroups) Then
varGroups = Arrayappend(varGroups, varChildGroups)
End If
Set doc = dclxn.GetNextDocument(doc)
If Not(doc Is Nothing ) Then
strGroupName$ = doc.GetItemValue("ListName")(0)
varGroups = Arrayappend(varGroups, strGroupName$)
End If
Next i
findGroupMembership = varGroups
thisExit:
Exit Function
errorHandler:
Msgbox "Error " & Err & ": " & Error$ & " encountered at line " & Erl & " of " & Getthreadinfo(1) & ".", , "Error encountered . . ."
Print "Error " & Err & ": " & Error$ & " encountered at line " & Erl & " of " & Getthreadinfo(1) & " . . ."
Resume thisExit
End Function