Pages

Tuesday, December 22, 2009

Check Access To Lotus Notes Database

'**********************************************************************************
'@Author : Karthikeyan A
'@Purpose : check access level to a database and return false if not designer or higher
'@Type : Function
'@Name : checkAccessToDatabase
'@Param : targetDB As NotesDatabase
'@Return : Boolean
'**********************************************************************************

Function checkAccessToDatabase (targetDB As NotesDatabase) As Boolean

'mark the flow of control getting inside the current function
checkAccessToDatabase=False

'declare the necessary variables and functions
Dim session As New NotesSession
Dim accessLevel As Integer

'if the handle for the target database is not
'set then prompt the user and exit
If Not targetDB.IsOpen Then
Msgbox "The database that you have selected is not a valid file" _
,,"Invalid file "
Exit Function
End If

'check the current user's access level for the selected database
accessLevel=targetDB.QueryAccess(session.UserName)

'if the user does not have designer or higher
'access then inform the user and exit
If accessLevel < ACLLEVEL_DESIGNER Then
Msgbox "You do not have sufficient access to perform this " & _
"operation in the chosen database",,"Access denied"
Exit Function
End If

'mark the flow of control getting inside the current function
checkAccessToDatabase=True
End Function

No comments:

Post a Comment