Domino Code Fragment

Code Name*
ACL adjustment from browser
Date*
10/07/1999
Source (or email address if you prefer)*
Zvonko.Paunoski@icn.siemens.de
IP address:.18.225.31.159
Description*
Type*
LotusScript
Categories*
Security, User Interface (Web), Workflow
Implementation:
Modify constants
Required Client:
NS4
Server:
4.6
Limitations:
Only a demo.
Shows ACL entries with role: [admin]
Adds ACL entries from group: WebAdmins
Comments:
With this two agents you can get and set ACL entries according to a role.
In this example the reole is: [admin]
Files/Graphics attachments (if applicable): Code:
Define a form like this:
Form name: AdminForm
Field1 name: CurrAdmins
Field1 type: Keywords
Field1 Choices, Use formula for choices: CurrAdmins
Field1 Label: Remove current Admin(s):
Field2 name: NewAdmins
Field2 type: Keywords
Field2 Choices, Use formula for choices: NewAdmins
Field2 HTML Attributes: "size=6"
Field2 Label: Add new Admin(s):
Field3 name: SaveOptions
Field3 type: Number
Field3 Default Value: 0
WebQueryOpen of the form: @Command([ToolsRunMacro]; "GetAdmins")
WebQuerySave of the form: @Command([ToolsRunMacro]; "SetAdmins")

Here the two form agents:

Agent GetAdmins:
Sub Initialize
Dim session As NotesSession
Dim db As NotesDatabase
Dim names As NotesDatabase
Dim userview As NotesView
Dim usergroup As NotesDocument
Dim doc As NotesDocument
Set session = New NotesSession
Set db = session.CurrentDatabase
Set doc = session.DocumentContext
Dim acl As NotesACL
Set acl = db.ACL
Dim entry As NotesACLEntry
Set entry = acl.GetFirstEntry
Dim curradmins As NotesItem
Set curradmins = doc.GetFirstItem( "CurrAdmins" )
While Not(entry Is Nothing)
' Msgbox "Entry: " & entry.Name
If entry.IsRoleEnabled( "[admin]" ) Then
Call curradmins.AppendToTextList(entry.Name)
' Msgbox "Role [admin] present."
End If
Set entry = acl.GetNextEntry(entry)
Wend
Set names = New NotesDatabase("", "names.nsf")
Set userview = names.GetView("($Users)")
Set usergroup = userview.GetDocumentByKey("WebAdmins")
If Not(usergroup Is Nothing) Then
doc.NewAdmins = usergroup.Members
End If
End Sub

Agent SetAdmins:
Sub Initialize
Dim session As NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Set session = New NotesSession
Set db = session.CurrentDatabase
Set doc = session.DocumentContext
Dim acl As NotesACL
Set acl = db.ACL
Dim entry As NotesACLEntry
Dim admins As NotesItem
Set admins = doc.GetFirstItem( "CurrAdmins" )
Forall oldadmin In admins.Values
Set entry = acl.GetEntry( oldadmin )
Call entry.Remove
Call acl.Save
End Forall
Set admins = doc.GetFirstItem( "NewAdmins" )
Forall newadmin In admins.Values
Set entry = acl.CreateACLEntry(newadmin, ACLLEVEL_MANAGER )
Call entry.EnableRole("[admin]")
End Forall
Call acl.Save
Print "[/" & db.FilePath & "/AdminForm/?OpenForm]"
End Sub