Domino Code Fragment

Code Name*
NotesACL and NotesACLEntry classes
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.139.62.103
Description*
The NotesACL class is used to give you access to a database's access control list (ACL). Once the ACL is accessible, NotesACLEntry can be used to retrieve all of the individual entries in the ACL using it's methods GetFirstEntry and GetNextEntry .
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
To determine the access level of a user, you must use the NotesACL and NotesACLEntry classes together. The NotesACL class is used to give you access to a database's access control list (ACL). Once the ACL is accessible, NotesACLEntry can be used to retrieve all of the individual entries in the ACL using it's methods GetFirstEntry and GetNextEntry. Each entry set to the NotesACLEntry object makes available several properties, including Name and Level. The Name property contains the name of the person, server, or group in the current entry, while the Level property contains the access level assigned to that person, server, or group.

ACL access levels are returned in the following format:

ACLLEVEL_NOACCESSNo access
ACLLEVEL_DEPOSITORDepositor access
ACLLEVEL_READERReader access
ACLLEVEL_AUTHORAuthor access
ACLLEVEL_EDITOREditor access
ACLLEVEL_DESIGNERDesigner access
ACLLEVEL_MANAGERManager access

In the example below, the ACL of this database is accessed and all entries are displayed along with their access level. Notice how the NotesACL is set from the NotesDatabase object, after which the NotesACLEntry objects are set from the NotesACL object.

Click here to view the example.

Dim session As New NotesSession 'Declare session as a new Notes session
Dim db As NotesDatabase
'Declare db as a NotesDatabase
Dim dbACL As NotesACL
'Declare dbACL as the Notes Database ACL
Dim ACLNames As NotesACLEntry
'Declare dbACLEntry as ACL Entry type
Set db = session.CurrentDatabase
'Set DB to the currently selected database
Set dbACL = db.ACL
'Set dbACL to the ACL property of the database
Set ACLNames = dbACL.GetFirstEntry
'Use the NotesACL method GetfirstEntry to set the first entry to the
While Not (ACLNames Is Nothing)
'Loop until the ACLNames variable is empty
Select Case ACLNames.Level
'Use a CASE statement to create a message based on the level of the entry
Case ACLLEVEL_NOACCESS
Messagebox ACLNames.Name & " has an access of NO ACCESS."
Case ACLLEVEL_DEPOSITOR
Messagebox ACLNames.Name & " has an access of DEPOSITOR."
Case ACLLEVEL_READER
Messagebox ACLNames.Name & " has an access of READER."
Case ACLLEVEL_AUTHOR
Messagebox ACLNames.Name & " has an access of AUTHOR."
Case ACLLEVEL_EDITOR
Messagebox ACLNames.Name & " has an access of EDITOR."
Case ACLLEVEL_DESIGNER
Messagebox ACLNames.Name & " has an access of DESIGNER."
Case ACLLEVEL_MANAGER
Messagebox ACLNames.Name & " has an access level of MANAGER."

Case Else
Messagebox "The ACL setting for " & ACLNames.Name & " is invalid."
End Select
Set ACLNames = dbACL.GetNextEntry(ACLNames)
'Move to the next entry in the ACL
Wend