Domino Code Fragment

Code Name*
Notes R4, you are attempting to add a user's name to an Access Control List (ACL) via LotusScript. When you add the user's hierarchical name to the ACL via the NotesACL New method, however, the user is still unable to access the database.
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.22.100.180
Description*
Add names to the ACL via LotusScript
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
Solution:
When adding names to a Notes ACL using the NotesACL New method, you must use the canonical form of the user's name. One way to
determine the canonical form of a hierarchical name using LotusScript is to use the LotusScript Evaluate command in combination with the
Notes @Name function. The following steps illustrate how to accomplish this.


1. Create a form resembling the following where ACLNames is a multi-value field:

----------------------------------------------------------------------------------------------------------------------------------------
Enter The Hierarchical Names you wish to add to Database ACL:


     

- Click to create new ACL
entries----------------------------------------------------------------------------------------------------------------------------------------


2. Enter the following code in the click event of the button:

Sub Click(Source As Button)

Dim acl As NotesACL
Dim servername As String
Dim newaclname As String
Dim dbname As String
Dim acllevel As Integer
Dim message As String
Dim newaclentry As NotesACLEntry
Dim check As String


Dim w As New notesuiworkspace
Dim uidoc As notesuidocument
Set uidoc = w.currentdocument
Set doc = uidoc.document


ACLName = doc.ACLNames

If doc.ACLNames(0) = "" Then
Messagebox "You must enter at least one name"
Exit Sub
End If


On Error 13 Resume Next 'Error 13 = Type mismatch
Do
ACLLevel = Cint(Inputbox _
("Enter ACL Level for this entry (0 - 6)"))
If ACLLevel < 0 Or ACLLevel > 6 Then Messagebox _
("The number must be between 0 and 6")
Loop While ACLLevel < 0 Or ACLLevel > 6
Err = 0


dbname = Inputbox ("Enter The Database File Name")
If dbname = "" Then Exit Sub
message = "Enter Notes Server (Leave blank for local)"
servername = Inputbox (message)


Dim dbase As New NotesDatabase (servername,dbname)

temp = dbase.title
If temp = "" Then
Messagebox ("The database could not be accessed.")
Exit Sub
End If


Set acl= dbase.ACL

ret = Evaluate("@name([canonicalize];ACLNames)",doc)

Forall names In ret

Set newaclentry = New NotesACLEntry (ACL, names, _
ACLLevel)
Call acl.Save()


End Forall
End Sub


3. Create a new document using this form.

4. Enter one or more names in the ACLNames field and click the button. You will be prompted to enter the proper ACL access level, a
database name and a server name. After entering this information, the canonical form of the name(s) entered should be added to the specified
ACL.