I am trying to figure out a way to write a LotusScript that will check ACL Entries to see if a Role is Enabled. I am using a previous post with my own changes (http://www-10.lotus.com/ldd/46dom.nsf/55c38d716d632d9b8525689b005ba1c0/ff02aa14d18e9a0685256b7a005b488f?OpenDocument) to do my inital check.
The problem with what I have is if a user is only a memember of a group in the ACL it fails. Is there a way for LotusScript to check the group entries to see if one of the members of the group is the current users?
I tried doing it with
Evaluate(|@IsMember(“| & sRole & |”; @UserRoles)|)
but on some older versions it crashes the notes client.
Thanks,
Brian
Here is my code:
Function RoleEnabled(sRole As String) As Integer
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
Dim uidoc As NotesUIDocument
Dim acl As NotesACL
Dim entry As NotesACLEntry
Dim entryList List As String
Dim i As Integer
Dim Entries As Variant
RoleEnabled = False
Set entries = Nothing
Set db = session.CurrentDatabase
Set acl = db.ACL
Set entry = acl.GetFirstEntry
i = 0
While Not entry Is Nothing
Forall role In entry.roles
If role = sRole Then
RoleEnabled = True
entryList(i) = entry.name
i = i + 1
End If
End Forall
Set entry = acl.GetNextEntry ( entry )
Wend
'// convert to array
If RoleEnabled Then
Redim entries (i -1)
i = 0
Forall e In entryList
entries (i) = e
i = i + 1
End Forall
End If
If entries Is Nothing Then
Messagebox _
"No entry for " & session.CommonUserName & _
" or " & session.UserName, “No entry”
RoleEnabled = 0 'User does not exist
Exit Function
End If
If entries.IsRoleEnabled( “sRole” ) Then
RoleEnabled = 1 'Role enabled
Else
RoleEnabled = 0 'Role not enabled
End If
End Function