I have a LotusScript agent that reads a database’s ACL. When it encounters a groupname in the ACL, is there a way (in LotusScript) to go to the names.nsf database
find the group and get a list of the members in that group?
thanks in advance.
I have a LotusScript agent that reads a database’s ACL. When it encounters a groupname in the ACL, is there a way (in LotusScript) to go to the names.nsf database
find the group and get a list of the members in that group?
thanks in advance.
Subject: Download IBM Notes group explore tool: Export nested group members to Excel
I am using ACL Dominator 7.1 which allows you to generate ACL reports, then export them to Excel. The nested groups are expanded during the export process and all nested group members are displayed in the Excel report. It allows you to easily see explicit member access to all mailboxes and apps.
Download: ACL Dominator for IBM Notes
http://www.notesmail.com/ACLdominator
tags: nested group, expand, expander, explore, explorer, explode, exploder, acl, nab, ibm dd, export, excel
topics: Expand group members and nested groups in @formula, Expand Lotus Notes (Nested) Groups to See Members, Get all members of Domino Directory Group, Group Migration (Distribution List) from Notes to Exchange, How to manage groups and their members easily in Lotus Notes Admin, IBM Limits on Nesting Groups in Domino, Is User A Member Of A (Nested) Group?, Lotus Notes Groups: Explore Members Inside a Group for Your ACLs, Lotus Notes NAB Group Explorer, Recursively get all users in a group, Retrieve Lotus Notes names from a nested group using @DBLookup, Working with groups in LotusScript
★ Crucial tools for IBM Lotus Notes and Domino administration and development…
Find the “crucial tools you need to succeed” including product descriptions, downloads, demos and testimonials.
Download and try the lite (free) version.
Better, stronger, faster productivity for administrators and developers.
Speed up IBM Lotus Notes and Domino administration and development with these crucial software tools.
Subject: How to get the members of a group
Yes here’s the idea:Get a NAB DB Handle in lotus script, a handle for “Groups” view and then use doc = view.getDocumentbykey(groupname), you will get the document handle for specific group name, now there is a multi value field in the document “Members”, you can access all the members in that group one by one.
Hope it would work for you.
Subject: How to get the members of a group
this is the code:
Dim session As New notessession
Dim db As notesdatabase
Dim nd_db As notesdatabase
Dim view As notesview
Dim g_doc As notesdocument
Set db = session.currentdatabase
server$ = db.server
Set nd_db = New notesdatabase("","")
flag = nd_db.open(server$, "names.nsf")
Set view = nd_db.getview("Groups")
' "DCI_Server" in the next line is a groupname and can be substituted with any value from ACL-retrieval
Set g_doc = view.getdocumentbykey("DCI_Server")
memfield = g_doc.getitemvalue("members")
Forall X In memfield
ename$ = X
' do what you want with ename$ ...
End Forall
Subject: This code doesn’t take nested groups into account
You’d have to modify the function to be able to call itself recursively until a) each name isn’t found in the groups view anymore and b) you don’t exceed your recursion nesting limit by 6 (to avoid circular references/endless loops) and the Domino doesn’t internally expand more than 6 group nestings anyway.
Subject: SOLUTION - ExpandGroup LotusScript NAB Group
‘==============================================’ 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 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
End If
GetGroupMembers = vGroupList
End Function ’ GetGroupMembers
'=============================================
’ Function 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
Subject: SOLUTION2 - ExpandGroup LotusScript NAB Group
My bad… the last solution had an error in it… The dbNAB was not open, so the sub was returning nothing.
Heres is the updated version:
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
Subject: RE: SOLUTION2 - ExpandGroup LotusScript NAB Group
Thanks a lot! That saved me a lot of time. Works perfectly!
Subject: RE: SOLUTION2 - ExpandGroup LotusScript NAB Group
Hi!
Thanks a lot for this code…
I have modified something to work it on my requirement… which will get all groups within group instead of members and it works!
I tried to put this as an agent.
When I manually run the agent (from the designer- agent - right click run), it was working perfectly.
However, when i tried to make my agent run as scheduled, it did not work as required anymore.
I did checked on the ff:
The agent signer is allowed to run scheduled agent.
When I checked on the log.nsf, there is an entry
error message : “Subscript out of range”
When I tried to check which line, it does not specify so i have put in some print commands to log inside the log.nsf.
have anyone encountered such problem.
Hope you can share your solution…
Thanks in advance!
Subject: Export nested groups to Excel
tags: expand, expander, explore, explorer, nested, group, export, acl, nab, ibm dd
topics: Expand group members and nested groups in @formula, Expand Lotus Notes (Nested) Groups to See Members, Get all members of Domino Directory Group, Group Migration (Distribution List) from Notes to Exchange, How to manage groups and their members easily in Lotus Notes Admin, IBM Limits on Nesting Groups in Domino, Is User A Member Of A (Nested) Group?, Lotus Notes Groups: Explore Members Inside a Group for Your ACLs, Lotus Notes NAB Group Explorer, Recursively get all users in a group, Retrieve Lotus Notes names from a nested group using @DBLookup, Working with groups in LotusScript
★ Crucial tools for IBM Lotus Notes and Domino administration and development…
Find the “crucial tools you need to succeed” including product descriptions, downloads, demos and testimonials.
Download and try the lite (free) version.
Better, stronger, faster productivity for administrators and developers.
Speed up IBM Lotus Notes and Domino administration and development with these crucial software tools.