Link to home
Start Free TrialLog in
Avatar of oosterbaan
oosterbaan

asked on

List of Roles

Hi experts,

How can I get a list of Members of a certain UserRole I use in the ACL of a database ?

Greetings Bob !!!
Avatar of Z_Beeblebrox
Z_Beeblebrox

As far a I know you can't. I am in the same position since I want to send an e-mail to all members of a certain role. I think I am going to create a loop which will iterate through each member of the ACL and check to see if they are a member of that role. However I would like to avoid using LotusScript to do this, but I can't find a function which will give me the members of the ACL.

Any ideas?

Zaphod.
Z beeblebrox : do all the persons who have the role are at the same Access Level ? If so, why don't you simply create a group in your Public Address Book and put their names in there. Then, just add the group to your ACL (with the role if need be) and then use the group name for your maillings ?

I would understand if you were to tell me that the option does not apply to your case.

Just for the fun of it, I'm coding something that will do what you want, just give me a couple of hours (can't do it at the same time I'm working).

Mchampou
What you suggest is of course possible, but it is much easier to maintain a list in the ACL of the database, rather than in the PAB. We have too many groups as it is in the PAB so creating a group with one member isn't the greatest. What I don't understand is why there isn't a function do to this, it seems like such a reasonable and standard thing to be doing.

Oh well,

Thanks,

Zaphod.
Hi,

I give up on the @function approach. The following script which I got out of the help file populates a field with the names of all people with a certain role.

Zaphod.    



Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim session As New NotesSession
Dim db As NotesDatabase
Dim acl As NotesACL
Dim entry As NotesACLEntry
Dim roleName As String
Dim foundRole As Variant
Dim sendMailTo As String
Set uidoc = workspace.CurrentDocument
Set db = session.CurrentDatabase
Set acl = db.ACL
roleName = "[Tech Coord]"
foundRole = False
' check to see if the role exists in the database
Forall r In acl.Roles
   If ( r = roleName ) Then
      foundRole = True
      Exit Forall
   End If
End Forall
If ( foundRole = False ) Then
   Messagebox _
    ( "Error, " & roleName & " is not a role" )
' if the role exists, check each acl entry to see if role
' is enabled for entry
' if so, add entry name to the People field
' on the current document,
' followed by a semicolon, the multi-value separator
     Else
          Set entry = acl.GetFirstEntry
          While Not ( entry Is Nothing )
               If ( entry.IsRoleEnabled( roleName ) = True ) Then
                    sendMailTo$ = sendMailTo$ & "; " & entry.Name
               End If
               Set entry = acl.GetNextEntry( entry )
          Wend
     End If
     Call uidoc.FieldSetText("TechCoord", sendMailTo$)
     
     Call uidoc.Refresh
Don't forget to account for groups in the ACL.  You'd need something [?dangerously?] recursive to cover the possibility of groups within groups -- not to mention (in a multi-domain environment with potentially disconnected users) a reliable way of finding and opening the right public NAB.
Generally that should not be an issue since you can do authentication, send e-mails, assign security, etc by groups, not just by names. So if the script runs Group1 as a member of the [Tech Coord] role then I can still use that group name in Reader fields or in the SendTo of an e-mail. I can't, off the top of my head, think of a reason inside notes that you would need to have a list of the actual names. The only place you might want such a thing would be if you wanted to display a list of names or something similar. If this is necessary then you would have to determine if a given member was a group (I don't know how you do this) then look up the address book to grab all of the members of that group. You would then of course have to check to see if any of those were groups. This is where DButler's comment regarding dangerously comes in. If group2 is a member of group1 and group1 is a member of group2, you can easily get into an infinite loop, so checks for things like this would be necessary.

Hopefully though, none of that is necessary.

Zaphod.
Avatar of oosterbaan

ASKER

Hi guys,

I have tried your script Z Beeblebrox, but i can't fill the value of a readersfield with a script, only with Formula language. What am I doing wrong?

Greetings Bob !!!
ASKER CERTIFIED SOLUTION
Avatar of Z_Beeblebrox
Z_Beeblebrox

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial