Home > Domino Tips > Developer > Domino > Retrieving all by role name
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

DOMINO

Retrieving all by role name


Andrew Young
06.26.2003
Rating: -4.50- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


View expert and member feedback to this tip.

This code will present a dialog listing of all roles specified for the database. Choose one of the listed roles to generate the next dialog, which lists all users associated with that role. You can take it from there...just a quick example of role retrieval via LotusScript.

Code

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


EXPERT FEEDBACK TO THIS TIP

  • 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

  • This code does not handle ACL entries that are not hierarchical (e.g., groupnames).

    ' z this1 = Strleft(this,"/O=")
    this1 = Strleft(this,"/")
    


    Do you have comments of your own? Let us know.


    Rate this Tip
    To rate tips, you must be a member of SearchDomino.com.
    Register now to start rating these tips. Log in if you are already a member.




    Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



    RELATED CONTENT
    Domino
    Mimic Lotus Notes Domino application functionality on the Web
    A single form to view and edit any Lotus Notes document
    DECS and DCR external data access considerations
    How to create non-scrolling Lotus Domino view headers on the Web
    Disabling the 'Submit' button on a form
    An easier way to update a rich text field
    Results from Default Notes Search have # of responses in brackets
    Lotus Notes/Domino veteran offers comprehensive list of app dev tools
    Notes to XML. . .and back again
    Creating thumbnail images using LS2J in LotusScript

    LotusScript
    LotusScript agent parses ACL to Microsoft Notepad
    LotusScript finds the first occurrence of a string from the right
    Clear Recent Contacts view and prevent repopulation in Lotus Notes 8.x
    Search Microsoft Active Directory with LotusScript
    Three steps to trap and handle save conflicts with LotusScript
    Troubleshoot agents by displaying LotusScript variables online
    LotusScript sorts lists alphabetically
    Run or restart Notes/Domino agents via text messages
    LotusScript code rebuilds corrupted busytime.nsf file
    Soft-code item names to facilitate LotusScript management

    RELATED RESOURCES
    2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
    Search Bitpipe.com for the latest white papers and business webcasts
    Whatis.com, the online computer dictionary

    DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



  • Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
    HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
    About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
    SEARCH 
    TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

    TechTarget Corporate Web Site  |  Media Kits  |  Site Map




    All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
      TechTarget - The IT Media ROI Experts