Moving Nested Groups

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.

Subject: Moving Nested Groups

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

End Sub

Subject: Moving Nested Groups

QuestionI might have a suggestion if you can answer some questions.

1> Do you want to move all groups or some groups?

2> Do you want to move the parent Groups, the child groups or both?

3> Do you waant to modify the groups?

4> Can you use copy and paste?

Shawn

Subject: RE: Moving Nested Groups

1> Do you want to move all groups or some groups?===================================

All groups that are in the ACL and all nested groups within the top level group

2> Do you want to move the parent Groups, the child groups or both?

====================================

Both

3> Do you waant to modify the groups?

====================================

Actually what we’ll prob do is back the groups up using DXL and store in a RT field in a document. But to answer you question No

4> Can you use copy and paste?

=====================================

The process will be managed in the background via LS agents.

Subject: RE: Moving Nested Groups

I am confused by the ACL piece. Do you want to copy all group entries in the ACL on DB “A” to DB “B” or from Address Book A to Address Book B?

Shawn

Subject: RE: Moving Nested Groups

Sorry Let me repost that since it made no sense.

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.

Shawn

Subject: RE: Moving Nested Groups

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.