Domino LotusScript Controlling Agent Run Location

I stumbled on a little routine I wrote years ago called IsAllowToRun. This routine allowed developers to set up an agent to run on multiple servers and multiple versions of a database but only run on the database that the server was set as administrator. This code is great for a template.

For example, if we had a database in our development and production system, we could set the agent to run on any server, and by setting the administrative server on those copies to their respective servers, the agent would run.

If someone replicated or copied the application to another server, the agent would not run until an ACL change. In addition, the agent could not run on the local machine unless a boolean variable was passed in the code to allow an agent to run locally.

I am sharing the code below and would love to hear if this is usable in your environment and what other tweaks you believe the code needs.

Sub Initialize  'Calling Program
   If Not IsAllowtoRun(True) Then 'Allow to run locally or on administrative server
      	Exit Sub
   End If
   If Not IsAllowToRun(False) Then 'Allow to run on administrative server
       Exit Sub
   End If
End Sub

Function IsAllowToRun(Locally As Boolean) As Boolean
   Dim session As New NotesSession
   Dim db As NotesDatabase
   Dim acl As NotesACL
   Dim agent As NotesAgent
   Dim State As Boolean
	
   State = False
   Set db = session.CurrentDatabase
   Set acl = db.ACL
   Set agent = session.CurrentAgent
	
   If agent.Servername = "" Then 
      If locally Then State = True 'Allow Agent to run on user local machine
   Else
      If acl.AdministrationServer = agent.ServerName Then '
         State = True' Agent running on Administrative server
      End If
   End If 
	
   IsAllowTorun = State
End Function