LOTUSSCRIPT/COM/OLE CLASSES
Examples: Examining and adjusting an access control list
1. This example displays whether uniform access is enforced, then accesses each entry in the ACL of a local database and displays its name.
Sub Initialize
Dim db As New NotesDatabase _
("", Inputbox("Name of database"))
Dim dbACL As NotesACL
Dim dbACLEntry As NotesACLEntry
Set dbACL = db.ACL
Set dbACLEntry = dbACL.GetFirstEntry()
If dbACL.UniformAccess Then
Messagebox "Uniform access in effect"
Else
Messagebox "Uniform access not in effect"
End If
While Not(dbACLEntry Is Nothing)
Messagebox dbACLEntry.Name
Set dbACLEntry = dbACL.GetNextEntry(dbACLEntry)
Wend
End Sub
2. This example indicates the maximum Internet access level for a database.
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim acl As NotesACL
Set db = session.CurrentDatabase
Messagebox acl.InternetLevel
If acl.InternetLevel = ACLLEVEL_READER Then
acl.InternetLevel = ACLLEVEL_EDITOR
End If
Call acl.Save
End Sub
3. This example finds an entry in the ACL of a local database and displays some of its properties.
Sub Initialize
Dim db As New NotesDatabase _
("", Inputbox("Name of database"))
Dim dbACL As NotesACL
Dim dbACLEntry As NotesACLEntry
Set dbACL = db.ACL
Set dbACLEntry = dbACL.GetEntry _
(Inputbox("Name of ACL entry?"))
Messagebox "Name: " & dbACLEntry.Name
Select Case dbACLEntry.Level
Case ACLLEVEL_NOACCESS : level = "No access"
Case ACLLEVEL_DEPOSITOR : level = "Depositor"
Case ACLLEVEL_READER : level = "Reader"
Case ACLLEVEL_AUTHOR : level = "Author"
Case ACLLEVEL_EDITOR : level = "Editor"
Case ACLLEVEL_DESIGNER : level = "Designer"
Case ACLLEVEL_MANAGER : level = "Manager"
End Select
Messagebox "Access level is " & level
If dbACLEntry.CanCreateDocuments Then
Messagebox "Can create documents"
Else
Messagebox "Cannot create documents"
End If
If dbACLEntry.CanDeleteDocuments Then
Messagebox "Can delete documents"
Else
Messagebox "Cannot delete documents"
End If
dbRoles = dbACLEntry.Roles
If Not(Isempty(dbRoles)) Then
Forall dbRole In dbRoles
Messagebox "Role: " & dbRole
End Forall
Else
Messagebox "No roles for this ACL entry"
End If
If NOT dbACLEntry.IsAdminServer Then
Messagebox "Entry does not have server
adminstration access."
Else
Messagebox "Entry may administer server."
End If
If NOT dbACLEntry.IsAdminReaderAuthor Then
Messagebox "AdminReaderAuthor access denied."
Else
Messagebox "AdminReaderAuthor access allowed."
End If
If dbACLEntry.CanCreateSharedFolder Then
Messagebox "Can create shared folders."
Else
Messagebox "Cannot create shared folders."
End If
End Sub
4. This example creates a new ACL entry in a database.
Sub Initialize
Dim db As New NotesDatabase _
("", Inputbox("Name of database"))
Dim dbACL As NotesACL
Dim dbACLEntry As NotesACLEntry
Set dbACL = db.ACL
ename = Inputbox("Name of new ACL entry?")
Set dbACLEntry = New NotesACLEntry _
(dbACL, ename, ACLLEVEL_DESIGNER)
Messagebox dbACLEntry.Name & " " &dbACLEntry.Level
Call dbACL.Save
End Sub
5. This example removes an ACL entry from a database.
Sub Initialize
Dim db As New NotesDatabase _
("", Inputbox("Name of database"))
Dim dbACL As NotesACL
Dim dbACLEntry As NotesACLEntry
Set dbACL = db.ACL
ename = Inputbox("Name of ACL entry to be removed?")
Set dbACLEntry = dbACL.GetEntry(ename)
Messagebox dbACLEntry.Name & " " & dbACLEntry.Level
Call dbACLEntry.Remove
Call dbACL.save
End Sub
6. This example adds a role to a database ACL and enables it for an ACL entry.
Sub Initialize
Dim db As New NotesDatabase _
("", Inputbox("Name of database"))
Dim dbACL As NotesACL
Dim dbACLEntry As NotesACLEntry
Set dbACL = db.ACL
ename = Inputbox("Name of ACL entry?")
Set dbACLEntry = dbACL.GetEntry(ename)
Call dbACL.AddRole("Role 3")
Call dbACLEntry.EnableRole("Role 3")
dbRoles = dbACLEntry.Roles
If Not(Isempty(dbRoles)) Then
Forall dbRole In dbRoles
Messagebox "Role " & dbRole
End Forall
Else
Messagebox "No roles for this ACL entry"
End If
Call dbACL.save
End Sub
7. This example displays and then changes the user type of an ACL entry in a database.
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim acl As NotesACL
Dim entry As NotesACLEntry
Set db = session.CurrentDatabase
Set acl = db.ACL
Set entry = acl.GetEntry("Lloyd Johnson")
If NOT entry.IsGroup Then
Messagebox entry.Name & " is not a group."
entry.IsGroup = True
Else
Messagebox entry.Name & " is a group."
End If
Call acl.Save
End Sub
See Also
Examining and adjusting an access control list
Glossary
Feedback on
Help
or
Product Usability
?
Help on Help
All Help Contents
Glossary