The QueryAccessRoles method of the NotesDatabase class allows you to obtain the user's role prior to performing an action or setting a data value. This approach enables you to customize the subroutine based on the Access Control List (ACL) roles for the user or to inform the user that he or she has insufficient access to perform a particular task, among other uses.
How It Works
This is a built-in Domino function. The roles assigned to the current user are returned by using the QueryAccessRoles method of the NotesDatabase class. Simply pass a Lotus Notes name to the method, and the roles are returned for a given database.
ImplementationExample 1
First, create one or more roles in the ACL for the Notes database application. Assign roles to users and user groups. Then set a database object and use the QueryAccessRole method to retrieve the current roles for the specified user. The following illustrates an action button that displays all roles assigned to the current user.
Sub Click(Source As Button) Dim s As NotesSession Dim db As NotesDatabase Dim roles as Variant Set s = new NotesSession Set db = s.CurrentDatabase roles = db.QueryAccessRoles(s.UserName) If Roles(0) = "" Then Msgbox "No roles assigned or this is a local database." Else Msgbox "You currently have the following roles:" +_ Chr$(13) + Implode (roles, Chr$(13)) End If End Sub
ImplementationExample 2
This second example illustrates how to conditionally execute statements based on the role assigned to the user. Here, you perform different tasks or elect not to perform tasks based on the role.
Sub Click(Source As Button) Dim s As NotesSession Dim db As NotesDatabase Dim roles as Variant Set s = new NotesSession Set db = s.CurrentDatabase roles = db.QueryAccessRoles(s.UserName) Forall role In roles If role = "[Developer]" Then Msgbox "Perform a task A" If role = "[TeamLead]" Then Msgbox "Perform a task B" If role = "[Employee]" Then Msgbox "Perform a task C" End Forall End Sub
Generate a Document in Another Database |
An Introduction to the Lotus Domino Tool Suite
Getting Started with Designer
Navigating the Domino Designer Workspace
Domino Design Elements
An Introduction to Formula Language
An Introduction to LotusScript
Fundamentals of a Notes Application
Calendar Applications
Collaborative Applications
Reference Library Applications
Workflow Applications
Web Applications
Design Enhancements Using LotusScript
Design Enhancements Using Formula Language
View Enhancements
Sample Agents
Miscellaneous Enhancements and Tips for Domino Databases
Data Management
Security
Application Deployment and Maintenance
Troubleshooting
Appendix A. Online Project Files and Sample Applications
Appendix B. IBM® Lotus® Notes® and Domino®Whats Next?