'Marc Tools\D. Databases\6. Tweak ACL of Catalog.nsf: Option Public Option Declare %INCLUDE "LSCONST.LSS" Sub Initialize ' ================================================== ' ' Agent: Tweak ACL of Catalog.nsf ' ' Author: Marc Champoux ' Created On: 2009 Aug 12 ' ' Description: ' This agent loops thru the selected server documents and then ' adds the server name to the ACL of the Catalog.nsf database ' to get around the issue of the catalog tasks that resets the ' ACL of the catalog.nsf db ' ' Usage: ' Select all the server documents in the Domino Directory and then ' run the agent. The agent will prompt you to select the catalog.nsf ' database from one of your server (i recommend selecting the ' one of the hub) ' ' Revisions: ' None yet. ' ' Notes: ' Yes, I'm fully aware that I'm doing much validation to make sure ' that the admin hasn't selected person docs prior to running this ' but I expect admins to be smart enough and only select server ' docs. ' ' ================================================== ' ================================================== ' Declarations ... ' ================================================== Dim CurrAgentName As String ' The current Agent name Dim CurrNUIWs As New NotesUIWorkspace ' The Notes UIWorkspace Dim CurrSession As New NotesSession ' The current Notes Session Dim CurrDB As NotesDatabase ' The current databases (the domino directory) Dim CurrSelectedDocs As NotesDocumentCollection ' The list of currently selected documents (hopefully server docs) Dim CurrServerDoc As NotesDocument ' The currently selected server document Dim CurrServerName As String ' The name of the server in the currently selected server document in string format. Dim CurrServerNameNN As NotesName ' The name of the server in the currently selected server document in NotesName format. Dim TargetDBSelection As Variant ' The array returned by the prompt to pick the catalog.nsf Dim TargetDb As NotesDatabase ' The catalog.nsf database that was selected Dim TargetDbACL As NotesACL ' The acl of the catalog.nsf database Dim TargetDbACLEntry As NotesACLEntry ' An entry from the ACL of the catalog.nsf Dim TargetDbSaveACLFlag As Integer ' A flag to tell me if we need to save the ACL or not ' ================================================== ' Part 1 - Initialize some variables ... ' ================================================== ' Set the agent name ... CurrAgentName = "Agent Tweak ACL of Catalog.nsf" ' Print something ... Print CurrAgentName + " : Starting ..." ' Get the current database ... Set CurrDb = CurrSession.CurrentDatabase ' Get the selected docs ... Set CurrSelectedDocs = CurrDb.UnprocessedDocuments ' Check if there is at least 1 document in the collection ... If CurrSelectedDocs.Count = 0 Then Messagebox "Sorry ... no documents selected. Please select at least 1 server document and try again." , MB_ICONEXCLAMATION , "Error - No Selection!" Print CurrAgentName + " : Finished with Error ..." Exit Sub End If ' Set the flag if we must save or not the ACL TargetDbSaveACLFlag = False ' ================================================== ' Part 2 - Get the Catalog.Nsf Database and open it ... ' ================================================== ' Prompt the person to select the catalog.nsf database ... TargetDBSelection = CurrNUIWs.Prompt ( 13 , "Select Catalog.nsf" , "Please select the catalog.nsf database on your domain hub:" ) ' Verify that something was selected ... If Isempty ( TargetDBSelection ) Then Messagebox "Sorry ... no catalog.nsf selected. Please select the catalog.nsf from your domain hub server and try again." , MB_ICONEXCLAMATION , "Error - No Catalog Selected!" Print CurrAgentName + " : Finished with Error ..." Exit Sub End If ' Verify that the database selected is not on local ... If TargetDBSelection (0) = "" Then Messagebox "Sorry ... the database you selected is on local. Please select the catalog.nsf from your domain hub server and try again." , MB_ICONEXCLAMATION , "Error - Database Selected on Local!" Print CurrAgentName + " : Finished with Error ..." Exit Sub End If ' Make sure we have the catalog.nsf selected ... If Lcase ( TargetDBSelection (1) ) <> "catalog.nsf" Then Messagebox "Sorry ... the database you selected is not named catalog.nsf. Please select the catalog.nsf from your domain hub server and try again." , MB_ICONEXCLAMATION , "Error - Database Selected is Not Catalog.nsf!" Print CurrAgentName + " : Finished with Error ..." Exit Sub End If ' Ok, now try to open the database ... Set TargetDb = CurrSession.GetDatabase ( TargetDBSelection (0), TargetDBSelection(1) , False) ' Check if the catalog database is opened ... If TargetDb.IsOpen = False Then Messagebox "Sorry ... I can't open the catalog.nsf database on the server you selected. Please verify that you can open the database from your Notes client and try again." , MB_ICONEXCLAMATION , "Error - Can't Open Catalog.nsf!" Print CurrAgentName + " : Finished with Error ..." Exit Sub End If ' Get the ACL of the catalog.nsf database ... Set TargetDbACL = TargetDb.ACL ' Make sure we got the ACL ... If TargetDbACL Is Nothing Then Messagebox "Sorry ... I can't get the ACL of the catalog.nsf database on the server you selected. Please verify that you can open the database from your Notes client and that you can view the ACL by clicking on File -> Database (or Application in R8) -> Access Control List and try again." , MB_ICONEXCLAMATION , "Error - Can't Open Catalog.nsf!" Print CurrAgentName + " : Finished with Error ..." Exit Sub End If ' ================================================== ' Part 3 - Now, loop in the selected server documents and add the ' name of each server to the ACL ... ' ================================================== ' Get the 1st document that was selected ... Set CurrServerDoc = CurrSelectedDocs.GetFirstDocument ( ) ' Loop While Not ( CurrServerDoc Is Nothing ) ' Make sure the document selected has the server name field .... If CurrServerDoc.HasItem ( "MailServer" ) Then ' Ok, now get the value of the MailServer field ... CurrServerName = CurrServerDoc.GetFirstItem ( "MailServer" ).Text ' Make sure that the document HAS a value in the MailServer field ... If Trim ( CurrServerName ) <> "" Then ' Ok, store the Server Name in a Notes Name object ... Set CurrServerNameNN = New NotesName ( CurrServerName ) ' Now blank out the last TargetDbACLEntry object prior to doing a search ... Set TargetDbACLEntry = Nothing ' Now search for this ACL Entry ... Set TargetDbACLEntry = TargetDbACL.GetEntry ( CurrServerNameNN.Abbreviated ) ' Check if we can't find it ... If TargetDbACLEntry Is Nothing Then ' Ok, we can't find this server to add it ... Set TargetDbACLEntry = TargetDbACL.CreateACLEntry( CurrServerNameNN.Abbreviated , ACLLEVEL_MANAGER ) ' Make sure that it's got the right user type and rights ... TargetDbACLEntry.IsServer = True TargetDbACLEntry.CanDeleteDocuments = True ' Set the flag for later ... TargetDbSaveACLFlag = True Else ' Check if the entry we found has Manager rights ... If TargetDbACLEntry.Level <> ACLLEVEL_MANAGER Then ' Get the level of this ACL entry to manager with delete rights TargetDbACLEntry.Level = ACLLEVEL_MANAGER ' Set the flag for later ... TargetDbSaveACLFlag = True End If ' Make sure it's a Server type If TargetDbACLEntry.IsServer = False Then ' Set the user type to server ... TargetDbACLEntry.IsServer = True ' Set the flag for later ... TargetDbSaveACLFlag = True End If ' Make sure the server can delete docs ... If TargetDbACLEntry.CanDeleteDocuments = False Then ' Set the user type to server ... TargetDbACLEntry.CanDeleteDocuments = True ' Set the flag for later ... TargetDbSaveACLFlag = True End If End If ' End of the "If TargetDbACLEntry Is Nothing Then" Else ' Oups ... the person probably selected something strange ... Messagebox "Sorry ... one of the document selected does not have a value in it's MailServer field ... please review your document selection and re-try." , MB_ICONEXCLAMATION , "Error - No Value in the MailServer Field" Print CurrAgentName + " : Finished with Error ..." Exit Sub End If ' End of the "If Trim ( CurrServerName ) <> "" Then" Else ' Oups ... the person probably didn't select server docs ... Messagebox "Sorry ... one of the document selected does not have a MailServer field ... please review your document selection and re-try." , MB_ICONEXCLAMATION , "Error - No MailServer Field" Print CurrAgentName + " : Finished with Error ..." Exit Sub End If ' End of the "If CurrServerDoc.HasItem ( "MailServer" ) Then" ' Get the next document that was selected ... Set CurrServerDoc = CurrSelectedDocs.GetNextDocument ( CurrServerDoc ) Wend ' ================================================== ' Ok, we are done ... print something in the status bar ... ' ================================================== ' Check if we need to save the ACL If TargetDbSaveACLFlag = True Then Call TargetDbACL.Save() End If ' Print something ... Print CurrAgentName + " : Finished ..." End Sub