I’m after a bit of LotusScript to move groups from one NAB to another. For the sake of this request lets not worry about the reason and accept that LotusScript is the only way that it can work, i.e. we can’t use any other admin tools.
In effect what I’m after is something that does something like the following. The “.CopyNestedGroups( )” line being the line that I’m after the code for.
'declarations etc
' set database objective etc
Set acl = db.ACL
Set entry = acl.GetFirstEntry
While Not (entry Is Nothing)
If entry.IsGroup Then
Call CopyNestedGroups( entry , targetNAB )
end if
Set entry = acl.GetNextEntry( entry )
Wend
I’ve searched this forum and have come across many examples of finding a user or users in nested groups. This is obviously slightly different.
The following code will create a NotesDocumentCollection of all groups nested below an initial group. The user can then do whatever they wish with the returned DC.
Dim session As NotesSession
Dim dbCurrent As NotesDatabase
Dim dbNAB As NotesDatabase
Dim viewNAB As NotesView
Dim docTemp as Notesdocument
Dim docGroup As NotesDocument
Dim dcGroups As NotesDocumentCollection
Dim dbArchNAB As NotesDatabase
Dim strReference As String
Sub Initialize
Set session = New NotesSession
Set dbCurrent = session.currentdatabase
Set dbNAB = New NotesDatabase( "source server", "names.nsf")
Set viewNAB = dbNAB.GetView("($VIMGroups)")
Set dcGroups = viewNAB.GetAllDocumentsByKey(Inputbox("Enter group name:"), True)
If dcGroups.Count = 0 Then
Msgbox ("Group not found")
Exit Sub
End If
Call BuildGroupCollection
Call copyGroups
End Sub
Sub BuildGroupCollection
Set docGroup = dcGroups.GetFirstDocument
While Not (docGroup Is Nothing )
Forall member In docGroup.Members
Set docTemp = viewNAB.GetDocumentByKey( Member )
If Not (docTemp Is Nothing) Then
Call dcGroups.AddDocument( docTemp )
End If
End Forall
Set docGroup = dcGroups.GetNextDocument( docGroup )
Wend
End Sub
Sub CopyGroups
Set dbArchNAB = New Notesdatabase("archive server", "archgroupsnames.nsf")
Set docGroup = dcGroups.GetFirstDocument
While Not (docGroup Is Nothing)
Set docTemp = docGroup.CopyToDatabase( dbArchNAB )
Set docGroup = dcGroups.GetNextDocument( docGroup )
Wend
Do you want to move database ACL entries or Address book group documents?
Both can be accomplished via script. The sample youprovided will move ACL entries. If you want to move groups for NAB ‘A’ to NAB ‘B’ you will need code that loops through a group view in A and copies to a doccollection in B then save the doc coll in the DB.
Groups. Given a list of groups I want to move them from one NAB to another NAB. We are moving databases that are infrequently used off our production environment to a smaller environment and need to produce a report of the groups so we know what to do with them.