Sub Click(Source As Button) Dim workspace As New NotesUIWorkspace Dim session As New NotesSession Dim db As NotesDatabase Dim nacl As NotesACL Dim nacle As NotesACLEntry Dim naclEnter As NotesACLEntry Dim initialRecipients() As String Dim availableRoles() As String Dim pickUser As String Dim pickRole As String Dim people As Integer Dim numRoles As Integer numRoles = 0 people = 0 Set db = session.CurrentDatabase Set nacl = db.ACL Set nacle = nacl.GetFirstEntry Forall r In nacl.Roles Redim Preserve availableRoles(numRoles + 1) availableRoles(numRoles) = Cstr(r) numRoles = numRoles + 1 End Forall If numRoles <> 0 Then pickRole = workspace.Prompt (PROMPT_OKCANCELLIST, "All Roles", "Please select role to examine.", availableRoles(0), availableRoles) Else Msgbox "No roles defined for this database", 0 + 16, "Error" Exit Sub End If If pickRole = "" Then Msgbox "Exiting at your request", 0 + 16, "Done" Exit Sub End If Do While Not (nacle Is Nothing) Set naclEnter = nacl.GetEntry( nacle.Name ) intFlag = naclEnter.IsRoleEnabled(pickRole) If intFlag Then this = Strright(nacle.Name, "CN=") this1 = Strleft(this,"/O=") Redim Preserve initialRecipients(people + 1) initialRecipients(people) = this1 people = people + 1 End If Set nacle = nacl.GetNextEntry(nacle) Loop 'now send mail, or perhaps create a list: pickUser = workspace.Prompt (PROMPT_OKCANCELLIST, "Those with the " & pickRole & " role", "This is a list of those with the " & pickRole & " role.",
initialRecipients(0), initialRecipients) If pickUser = "" Then Msgbox "Exiting at your request", 0 + 16, "Done" Exit Sub End If Msgbox pickUser End Sub
- This tip may not consider situations where there are no roles in the database (at least, under ND6). This case displays a blank dialog.
- The code here assumes that all ACL entries are of the form CN=Name/O=Org, which doesn't work for groups, usernames with an OU= component or entries of the form "*/Org". One should use NotesName class to get the common name.
- I disagree with the idea of displaying just the common name even if it were done correctly because there might be other users with the same common name. Instances like this are what those extra username components are for.
MEMBER FEEDBACK TO THIS TIP
' z this1 = Strleft(this,"/O=") this1 = Strleft(this,"/")
Do you have comments of your own? Let us know.