Manage Learn to apply best practices and optimize your operations.

Report of All Users and Groups on a Single Mail Server

If you're like us, and build hierarchical organizations in the address book, sometimes you would like to know who is in the organization, groups, and names. We also had a need to make sure which server everyone's mail box was on, in an effort to consolidate a large department on one server.

This agent works off of one group name, the one at the top of the hierarchy. It creates a number of documents in the database it runs from. One is a list of all the groups it found (at all depths) contained in the supergroup. It also creates one document per mail server, with a list of the people from the heirarchy that have mail on that particular server. By tweaking the agent a number of other useful reports could be developed as well.


Option Public
Option Explicit

Dim arrGroups(100) As String
Dim arrMembers(500) As String
Dim arrMemsrvr(500) As String
Dim arrMemmaildb(500) As String
Dim arrUniquesrvrs(50) As String
Dim idxgrp_r As Integer
Dim idxgrp_w As Integer
Dim idxmem As Integer
Dim idxUniqsrvr As Integer

Sub Initialize
Dim s As New NotesSession
Dim thisdb As NotesDatabase
Dim addrdb As NotesDatabase
Dim maildb As Notesdatabase
Dim nosvrdoc As NotesDocument
Dim profilemem As NotesDocument
Dim grpdoc As NotesDocument
Dim ppldoc As NotesDocument
Dim rptdoc As NotesDocument
Dim this_pers As NotesName
Dim this_srvr As NotesName
Dim doc As NotesDocument
Dim grpview As NotesView
Dim pplview As Notesview
Dim varMembers As Variant
Dim vartemp As Variant
Dim tempitem As NotesItem
Dim rptbody As NotesRichTextItem
Dim i As Integer
Dim j As Integer
Dim flag As Integer
Dim topgroup As String

topgroup = "Top of the Heap" ' this is the super group we start from
Set addrdb = s.GetDatabase("aServer/ourOrg", "names.nsf")
Set thisdb = s.CurrentDatabase
Set grpview = addrdb.GetView("Groups")
Set grpdoc = grpview.GetDocumentByKey(topgroup)
idxgrp_r = 0
idxgrp_w = 0
idxmem = 0

Do While Not (grpdoc Is Nothing)
varMembers = grpdoc.GetItemValue("Members")
Forall names In varMembers
If (Instr(names, "//") > 0) Then ' a // indicates a person name
idxmem = idxmem + 1
arrMembers(idxmem) = names
Else 'must be another group
idxgrp_w = idxgrp_w + 1
arrGroups(idxgrp_w) = names
End If
End Forall

' read next group name from array
idxgrp_r = idxgrp_r + 1
Set grpdoc = grpview.GetDocumentByKey(arrGroups(idxgrp_r))
Loop

' at this point we have an array of groups and an array of names
' change the view of the address book and get all the mail db names and mail server names for the people
Set pplview = addrdb.GetView("($VIMPeople)")
For i = 1 To idxmem
Set this_pers = New NotesName(arrMembers(i))
Set ppldoc = pplview.GetDocumentByKey(this_pers.abbreviated())
If Not (ppldoc Is Nothing) Then
vartemp = ppldoc.GetItemValue("MailFile")
arrMemmaildb(i) = vartemp(0)
vartemp = ppldoc.GetItemValue("MailServer")
arrMemsrvr(i) = vartemp(0)
End If
Next

'********************************
'********************************
' at this point we have an array of servers and maildb filenames to go with the users, so we can start doing the reports

'*******************************
'*******************************
' create a report showing all the groups searched

Set rptdoc = thisdb.CreateDocument()
Call rptdoc.ReplaceItemValue("Subject", "Groups found in the organization " + topgroup)
Set rptbody = rptdoc.CreateRichTextItem("Body")
For i = 1 To idxgrp_r
Call rptbody.AppendText(arrGroups(i))
Call rptbody.AddNewLine(1)
Next
rptdoc.Form = "Report"
Call rptdoc.save(True,False)

' now print reports for users by servers
' first we need a list of unique server names
idxUniqsrvr = 0
For i = 1 To idxmem
If (idxUniqsrvr > 0) Then ' check the existing unique names for a match
flag = False
For j = 1 To idxUniqsrvr
If arrMemsrvr(i) = arrUniquesrvrs(j) Then
flag = True
End If

Dig Deeper on Domino Resources - Part 6

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close