Agent to Adjust ACL Setting

Author: Tripp W Black

Created: 10/30/2000 at 03:37 PM

 

Category:
Notes Developer Tips
Agents

Restricting Database Access after hours

This week's dev tip was submitted to the Lotus411
Tips by John P. Warner

This is a quick way to restrict access to a Notes database
for those customers who do not fully understand Notes
security and want the database "shut down" after hours. (My
customer physically wanted the server to be shut down on a
nightly basis)

I created a scheduled agent that runs at 8:00 pm nightly to
modify all entries in the ACL except Managers and set their
access to No Access. This restricts all users while
allowing you to still administer the server after hours. I
also wrote another scheduled agent to grant access that
runs at 8:00 am.

Code:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim acl As NotesACL
Dim acl_entry As NotesACLEntry

On Error Goto ProcessError

Set nlog = New NotesLog("Restrict Access")
Call nlog.OpenAgentLog()
Call nlog.LogAction("Agent Started")

Set db = session.CurrentDatabase

If (db Is Nothing) Then
Call nlog.LogAction("db is nothing")
Exit Sub
End If

Set acl = db.ACL
Set acl_entry = acl.GetFirstEntry()

'ACL Level Access Key
'ACLLEVEL_NOACCESS = 0
'ACLLEVEL_DEPOSITOR = 1
'ACLLEVEL_READER = 2
'ACLLEVEL_AUTHOR = 3
'ACLLEVEL_EDITOR = 4
'ACLLEVEL_DESIGNER = 5
'ACLLEVEL_MANAGER = 6


While Not (acl_entry Is Nothing)
Select Case (acl_entry.Level)
Case ACLEVEL_DEPOSITOR:
Case ACLLEVEL_READER:
Case ACLLEVEL_AUTHOR :
Case ACLLEVEL_EDITOR :
Case ACLLEVEL_DESIGNER:
acl_entry.Level = ACL_NOACCESS
End Select
Set acl_entry = acl.GetNextEntry(acl_entry)
Wend

'save changes to the ACL
Call acl.Save
Call nlog.LogAction("agent completed successfully")
Call nlog.Close

Exit Sub

ProcessError:
Call nlog.LogError(Err,Error$ & " occured at line " & Erl)
Exit Sub

End Sub


previous page