role [Keys] which i created in the acl . By putting the the code below in a
Script Library ( which i named "Access1" ) i only had to write it once , if i
had more roles i could of passed the role as a parameter as well but this was
not required .
To use the below code in a form go to the declarations and type
this allows use of the scripting library .
then you can call the procedures in the scripting library .
In my case i used it in the form procedure querymodechange as follows
Sub Querymodechange(Source As Notesuidocument, Continue As Variant)
' See Script Libraries - Access1 and the procedure checkaccess for details
Call checkaccess(Source ,Continue) ' check to see if the user is allowed
to edit the document
I Know there is other methods of doing this but for what i wanted it suits fine
and demonstrates the use of script libraries .
Any comments -
e-mail me at Garreth.Kelly@ireland.com
Sub CheckAccess(Source As Notesuidocument, Continue As Variant)
' The purpose of this code is to only allow users with access to the [Keys]
role to exit the document
' Written by Garreth Kelly Feb 2000
Dim db As NotesDatabase
Dim session As New NotesSession
Dim acl As NotesACL
Dim Entry As NotesACLEntry
Dim newName As String
boxType& = MB_OK 'Constant from the file lsconst.lss - value of MB_OK =
0 , the file lsconst.lss is declared in the from global of xLookup .
Set db = session.CurrentDatabase
Set acl = db.ACL ' get the current databases access control list
newName = Cstr(session.UserName) ' returns the current user logged on
Set Entry = acl.GetEntry( newName ) ' get the users entry in the acl
On Error Goto Err1
If Entry.IsRoleEnabled( "[Keys]" ) Then ' check to see if the user is part
of the role [keys]
Continue = True
Continue = False ' the user isn't part of the role don't allow access
to edit the document
Messagebox "You don't have sufficient access to edit this document",
Continue = False
Messagebox "Unknown Error", boxType& ,"Error" ' this message will appear
if the currently logged on users name is not in the nab .