Wednesday, December 23, 2009

Checking For User's Role

'**********************************************************************************'@Author : Karthikeyan A
'@Purpose : To check whether a user has a specified role in a database or not
'@Type : Function
'@Name : isRoleEnabled
'@Param : userName As String,db As NotesDatabase,roleName As String
'@Return : Boolean ( True if user has a specified role in the database provided, false otherwise)
'@Status : Working
'@UpdatedHistory
'@Updatedby :
'**********************************************************************************

Function isRoleEnabled(userName As String,db As NotesDatabase,roleName As String) As Boolean

'mark theflow of control getting inside the current function
isRoleEnabled =False

'handle errors in case of abrupt termination
On Error Goto errHandler

Dim userRoles As Variant
Dim acl As notesacl
Dim aclEntry As NotesACLEntry

'set the handle to access the access control list of the provided database
Set acl=db.ACL

'get the handle to fetch the details relevant to user name provided in the parameter list
Set aclEntry=acl.GetEntry(userName)

userRoles=aclEntry.Roles
Forall roles In userRoles
'mark the flow of control getting out of the current function
If roles=roleName Then isRoleEnabled=True
End Forall

Exit Function
errHandler:
Exit Function
End Function

No comments:

Post a Comment