• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 944
  • Last Modified:

How do I verify user roles on my ACL

Hello.  I am attempting to write a lotus script that will allow the database to verify user roles when a user logs on.  I have a role that I am only giving access to one form via a link. This role should not have access anywhere else.  I thought I would write a lotus script on the Global Init that would check the ACL and then close the database or not give the user access who is on this one specific role.  This code is giving me a type mismatch error and I think is one step off from working.  Can anyone help. Thank you.
Sub Initialize
     Dim session As New NotesSession
     Dim db As NotesDatabase
     Dim acl As NotesACL
     Set db = session.CurrentDatabase
     Set acl = db.ACL
     If acl.Roles = "[Off Account]"  Then
          db.close
     End If
     
     
End Sub
0
wrigh066
Asked:
wrigh066
1 Solution
 
SysExpertCommented:
Axel Matthies
05 Feb 2001, Rating 4.20 (out of 5)
The only way in script to check the roles of a user in the IsRoleEnabled function from NotesAclEntry - class. But this function don't work, when the user is member of a group and the the role is enabled for the group.
I have create a function which checks, whether a role is set for a User even if he is a member of a group.

Example how the function is calling:


If RoleEnabled("[Admin]") Then
  Messagebox "Role Admin is set"
Else
  Messagebox "Role Admin not set"
End If



Code


Function RoleEnabled(sRole As String) As Integer
     
     Dim vResult As Variant
     
     vResult = Evaluate(|@IsMember("| & sRole & |"; @UserRoles)|)
     
     If vResult(0) = 1 Then
          RoleEnabled = 1
     Else
          RoleEnabled = 0
     End If  'If vResult(0) = 1
     
End Function

-----------------------------

I hope this helps !
0
 
HemanthaKumarCommented:
You can use stratight forward method available in LS

Example:

Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
Dim uidoc As NotesUIDocument
Dim acl As NotesACL    
Dim entry As NotesACLEntry
Set db = session.CurrentDatabase
Set acl = db.ACL
Set entry = acl.GetEntry( session.CommonUserName )
If entry Is Nothing Then
  Set entry = acl.GetEntry( session.UserName )
End If
If entry Is Nothing Then
  Messagebox _
  "No entry for " & session.CommonUserName & _
  " or " & session.UserName,, "No entry"
  Exit Sub
End If
If entry.IsRoleEnabled( "[Supervisor]" ) Then
  Set uidoc = workspace.ComposeDocument( "", "approval" )
Else
  Set uidoc = workspace.ComposeDocument( "", "request" )
End If

~Hemanth
0
 
CRAKCommented:
So far I've always been using an evaluate like described by SysExpert. Works well!
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
HemanthaKumarCommented:
Why would you go round about way if there is a straight forward methods available in LS ?
0
 
wrigh066Author Commented:
Thank you this script is exactly what I needed!! I appreciate your help.
0
 
CRAKCommented:
Hemanth, I started doing so back in R4.5. Since it's a working one-liner, it's very tempting to just grab it again. I don't think I've ever come in a situation in R5 where I had to determine the assigned userroles. I might use the proper LS-way....
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now