Personal Blog of Thomas Hampel - Creative Mythbusting in Development and Collaboration

Query results for : QuickR

QuickR - How to count the number of registered users?- 14 June 2012 - (0) Comments

Thomas Hampel
 14 June 2012

Lets assume an IBM QuickR environment where all users are allowed to access the Domino server that QuickR runs on.
How would an administrator report the number of users?

Using the log.nsf is not the right place, because users leave a trace there just by accessing (e.g.) the Domino directory, but not QuickR.
A better way is to use the QuickR Place Catalog (placecatalog.nsf) on your Quickr server. It's design is set to not show up in the Open Database dialog, so you either need to type in the filename or use the Admin client to open it up.

Image:QuickR - How to count the number of registered users?
It contains a view named "Total Places By Member" which will show the total number of quickr users across all places including those with Anonymous access, all categorized by user name.

Image:QuickR - How to count the number of registered users?
So to identify the number of QuickR users, collapse everything
Image:QuickR - How to count the number of registered users? in this view so that you can see the first category only.
What you can see is  member number and the user name  
Image:QuickR - How to count the number of registered users?
Now scroll down to the last entry in this view - the last number displayed there is the total number of unique users.


Be aware:
  • If there are places which grant access to a group, then groups displayed in this view need to be resolve recursively
  • If Anonymous access is enabled , special licensing rules apply

If anyone would like to do this automatically, here is some LotusScript code which might help.



%REM

        Agent Count number of registered QuickR Users
        Created Jun 14, 2012 by Thomas Hampel
        Description:
        A simple agent to report QuickR user names - feel free to modify
%END REM
Option Public
Option Declare
Const QuickRServer$ = "Domino-Name-Of-QuickR-Server"
Const QuickRPlaceCatalog$ = "PlaceCatalog.nsf"
Const QuickRViewName$ = "TotalPlacesByMember"
Const NABServer$ = "Domino-Name-Of-QuickR-Server"
Const NABFilename$ = "names.nsf"
Dim userlist List As boolean
Sub Initialize
        Dim nab As New NotesDatabase (NABServer$, NABFilename$)
        Dim PlaceCatalog As New NotesDatabase (QuickRServer$, QuickRPlaceCatalog$)
        Dim view As NotesView
       
        If Not NAB.IsOpen Then
                Print "Unable to open Domino Directory : " & NABServer$ & " - " & NABFilename$
                end
        End If
       
        If Not PlaceCatalog.Isopen then
                Print "Unable to open QuickR PlaceCatalog : " & QuickRServer$ & " - " & QuickRPlaceCatalog$
                End
        End If
       
        '# load all elements into list object
        Set view = PlaceCatalog.getView (QuickRViewName$)
        Call LoadNamesFromView (view)
               
        '# resolve membership
        Call ResolveGroupMembers
       
        '# output result
        Print "Total number of unique users is " & CountUsers()
       
        '# Anonymous access...
        If IsElement (userlist ("anonymous")) Then
                Print "Anonymous access to one or more places is ENABLED"
        Else
                Print "Anonymous access to one or more places is DISABLED"
        End If
End Sub

Function LoadNamesFromView (View As NotesView)
        Dim doc As NotesDocument
        Dim tDoc As NotesDocument
        Dim usernameArray As variant
        Dim usercount#
        '# exit if the view is not valid
        If view Is Nothing Then Exit Function
        view.AutoUpdate = False

        Set doc = view.getFirstdocument
        While (Not doc Is Nothing)
                Set tdoc = view.getNextDocument (doc)
                If doc.isValid Then
                        usernameArray = Evaluate (|@Unique(@Trim(PlaceOwners : PlaceManagers : PlaceEditors : PlaceAuthors : PlaceReaders))|, doc)
                        ForAll u In usernameArray
                                '# add name to list of unique users
                                userlist (u)= True
                                usercount# = usercount + 1
                        End ForAll
                End If
                Set doc = tdoc
        Wend
        Print "Found " & usercount# & " entries across all places."        
End Function

Function expandGroupNames(GroupName As String, GroupMemberArray As Variant) As Boolean
        on Error GoTo errorHandler
        expandGroupNames = False
        If Len(Trim$(GroupName)) = 0 Then
                GoTo functionExit '# if no name is passed, don't even try to resolve the group name
        End If
 
        '# Undocumented @Formula from http://www-304.ibm.com/support/docview.wss?uid=swg21101582
        '# Input from http://www.dominoguru.com/pages/01202009030630.html
       
        GroupMemberArray = Evaluate(|@ExpandNameList("| & NABServer$ & |":"| & NABFilename$ & |";"| & GroupName$ & |")|)
        GroupMemberArray = ArrayUnique(GroupMemberArray, 5)
        If UBound(GroupMemberArray) = 0 Then
                '# if there's only one group member, check to see if it's valid
                if StrCompare(GroupMemberArray(0), GroupName$, 5) = 0 Then
                        '# if the only member found is the group name itself, the group couldn't be resolved
                        GoTo functionExit
                 End If
          End If
        expandGroupNames = True
       
functionExit:
Exit Function

errorHandler:
        MsgBox "Error " & Err & ": " & Error & " at line " & Erl & " of " & GetThreadInfo(1) & ".", , "Error encountered!"
        Print "Error " & Err & ": " & Error & " at line " & Erl & " of " & GetThreadInfo(1)
        Resume functionExit
End Function

Function ResolveGroupMembers As Integer
        Dim GroupMemberArray As Variant
        '# loop all users found
        ForAll user In userlist
                '# try to resolve the existing list entry
                If expandGroupNames (ListTag(user), GroupMemberArray) Then
                        ForAll members In GroupMemberArray
                                '# add the new name to the list
                                userlist (members) = true
                        End ForAll
                End If
        End ForAll
End Function


Function CountUsers As Long
        Dim count&
        ForAll user In userlist
                count& = count + 1
        End ForAll
        Countusers = count&
End Function
Go ElsewhereSubscribe to RSSAboutStay ConnectedAnd More
Thomas Hampel, All rights reserved.