3

I need to get all the username of a specific role so that I would be able to send a mail to all user's who has that role access. How would I able to accomplish this task?

I saw this link,

How do I get all users who have a specified role?

Is there no other way to get all the valid username that can be used in the SendTo? Without having this problem? Though I didn't try the NotesACL. I am new in Lotus Notes Development.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • What do you mean by "this problem"? That post claims that iterating through the ACL entries seems to be a performance killer, but it doesn't cite any data to support that claim. It should not be slow at all. – Richard Schwartz Jul 18 '13 at 14:22
  • 1
    Hi Richard, Well basically it's my fault since when I read that I still have no idea about notesACL, but I'm really in a rush so I asked this question. Now I clearly understand how notesACL works with the help of Knut. I really have a long road to go in learning notes development been here for just 3 weeks. Thanks a lot. God Bless. – Kevin Patrick Tan Jul 19 '13 at 06:30

1 Answers1

6

If you have a bit influence how ACL entries are look like then you should be able to achieve a good solution. Following code collects all entries in ACL with the certain role and accepts only those entries which are of type Person or Person group.

Function GetRoleMembers(roleName As String) As String
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim acl As NotesACL
    Dim entry As NotesACLEntry
    Dim sMembers As String 
    Set db = session.CurrentDatabase
    Set acl = db.ACL
    sMembers = ""
    Set entry = acl.GetFirstEntry
    While Not ( entry Is Nothing )
        If entry.IsRoleEnabled( roleName ) And entry.IsPerson Then
            sMembers = sMembers + entry.Name & ","
        End If
        Set entry = acl.GetNextEntry( entry )
    Wend
    GetRoleMembers = sMembers
End Function

The Function returns a comma separated list of all persons and groups with given role. You can test this function with

Print GetRoleMembers("[Test]")

Make sure that users whom you want to send emails are assigned to type Person or Person group. You can set user's type in ACL

enter image description here

Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
  • Hi Knut Herrmann, Thanks a lot. It worked and I'm sorry if this question is so simple. Guess I still need to study more, though I asked this since I have no more time to learn for the deadline. But because of you I clearly understood the NotesACL which I never used this past 3 works after starting in lotus notes development. God Bless. – Kevin Patrick Tan Jul 19 '13 at 06:25
  • 1
    You're welcome. It's a good decision to develop with IBM Notes Domino. I've been doing it since 1992. Have fun! – Knut Herrmann Jul 19 '13 at 07:00