Copy Complete Acl

Copy all entries and roles from the ACL of one database to the ACL of another.
Has to be a time saver!
Option Public
Option Declare

Declare Function NEMGetFile Lib "nnotesws" ( wUnk As Integer, Byval szFileName
As String, Byval szFilter As String, Byval szTitle As String ) As Integer

Sub Initialize
'This Agent will refresh the design on all specified databases and verify the
ACL is configured correctly.
Dim SrcDB As NotesDatabase
Dim DestDB As NotesDatabase
Dim SrcDBName As String
Dim DestDBName As String
Dim done As Variant

SrcDBName = getFileName ("Select Source Database")
If SrcDBName = "" Then Done = True
If Not Done Then
DestDBName = getFileName ("Select Destination Database")
If DestDBName = "" Then Done = True
If Not Done Then
Set SrcDB = New NotesDatabase("",SrcDBName)
Set DestDB = New NotesDatabase("",DestDBName)
If SrcDB.Title = "" Or DestDB.Title = "" Then
Messagebox "Could not get one of the DBs"
ConfirmACL SrcDB,DestDB
End If
End If
End If
End Sub
Sub ConfirmACL(SrcDB As NotesDatabase, DestDB As NotesDatabase)
Dim SrcACL As NotesACL
Dim DestACL As NotesACL
Dim Entry As NotesACLEntry
Dim NEntry As NotesACLEntry
Dim Roles As Variant
Dim TRoles As Variant
Dim Found As Variant
Dim I As Integer, J As Integer

Set SrcACL = SrcDB.ACL
Set DestACL = DestDB.ACL

SyncACLRoles SrcACL,DestACL

Set Entry = SrcACL.GetFirstEntry
While Not Entry Is Nothing
Set NEntry = DestACL.CreateACLEntry(Entry.Name, Entry.Level)
NEntry.CanCreateDocuments = Entry.CanCreateDocuments
NEntry.CanCreatePersonalAgent = Entry.CanCreatePersonalAgent
NEntry.CanCreatePersonalFolder = Entry.CanCreatePersonalFolder
NEntry.CanDeleteDocuments = Entry.CanDeleteDocuments
NEntry.IsPublicReader = Entry.IsPublicReader
NEntry.IsPublicWriter = Entry.IsPublicWriter
SyncEntryRoles NEntry, Entry, DestACL

Set Entry = SrcACL.GetNextEntry(Entry)
End Sub
Sub SyncACLRoles(SrcACL As NotesACL, DestACL As NotesACL)
Dim Roles As Variant
Dim TRoles As Variant
Dim Found As Variant
Dim i As Integer, j As Integer

Roles = DestACL.Roles
TRoles = SrcACL.Roles

For i = 0 To Ubound(TRoles)
If TRoles(i) <> "" Then
Found = False
For j = 0 To Ubound(Roles)
If Roles(j) <> "" Then
If TRoles(i) = Roles(j) Then
found = True
Exit For
End If
End If
Next j
If Not Found Then
DestACL.AddRole Mid$(TRoles(i),2,Len(TRoles(i))-2)
End If
End If
Next i


End Sub
Sub SyncEntryRoles(NEntry As NotesACLEntry, Entry As NotesACLEntry, ACL As
Dim ACLRoles As Variant
Dim TRoles As Variant
Dim i As Integer, j As Integer

ACLRoles = ACL.Roles
TRoles = Entry.Roles

For i = 0 To Ubound(ACLRoles)
If ACLRoles(i) <> "" Then
For j = 0 To Ubound(TRoles)
If TRoles(j) <> "" Then
If ACLRoles(i) = TRoles(j) Then
Exit For
End If
End If
End If

This was last published in November 2000

Dig Deeper on Domino Resources - Part 3

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...