As a follow-up to my previous tool that let you analyze the ACL of a database, I built another tool for my admin. For different reasons, we need to keep the mailbox of terminated users, sometimes for a shorter time but sometimes for long periods of time. As far as I understand it, if a traditional approach was used to remove a user from the system, the mail file would also be deleted. So the admin put the terminated user in the Deny Access group and change the ACL of the mailfile to include a manager, supervisor or replacement.
But because of this process, AdminP will not remove the terminated user from all the groups he/she is listed in. When you have hundreds of groups, many of them nested, this could be a real headache. So I was asked to build something simple that allows us to remove one or more specified users from all groups in the Domino Directory. Below is the result. Enjoy!
First you create a form with 3 fields:
'SaveOptions' has a default value of "0" (to prevent the form from being saved).
'Users' is a Names field, getting it's values using the addresses dialog. The field is multi-value and using New Line as separator.
'LogResult' is a multi-value text field, again with New Line as separator.
Finally I add a button to the action bar to remove the user(s). The Lotusscript code is listed below. It is using my class for mail notifications that I blogged about last year to send a confirmation to the user running the agent. This is useful for example when you need to log all data changes done to a system.
Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim session As New NotesSession
Dim nab As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim members As Variant
Dim newmembers List As String
Dim delmembers List As String
Dim users As Variant
Dim userlist List As String
Dim user As NotesName
Dim nmcnt As Integer
Dim newarray() As String
Dim ret As Integer
Dim removelog List As String
Dim userarr As Variant
Dim mail As NotesMail
Dim mailtext As String
Dim updated As Boolean
' *** Make sure the operator is sure
ret = Msgbox("Are you sure?",4+32+256,"WARNING")
If ret = 7 Then
' *** Get a list of users in field 'Users'
Set uidoc = ws.CurrentDocument
users = Split(uidoc.FieldGetText("Users"),Chr$(13))
Forall u In users
Set user = New NotesName(u)
userlist(Fulltrim(user.Common)) = Fulltrim(user.Common)
' *** Get all groups in NAB and process them one by one
Set nab = New NotesDatabase(session.CurrentDatabase.Server,"names.nsf")
Set view = nab.GetView("Groups")
Set doc = view.GetFirstDocument
Do While Not doc Is Nothing
Print "Processing " & doc.GetItemValue("Listname")(0)
updated = False
' *** Get members in the group and create a list of the ones to keep
members = doc.GetItemValue("Members")
nmcnt = 0
Forall m In members
Set user = New NotesName(m)
If Iselement(userlist(Fulltrim(user.Common))) = False Then
' User is not among the ones to delete
newmembers(Fulltrim(user.Common)) = Fulltrim(m)
nmcnt = nmcnt + 1
delmembers(Fulltrim(user.Common)) = Fulltrim(m)
updated = True
' *** Build array of members to keep
Redim newarray(nmcnt) As String
nmcnt = 0
Forall nm In newmembers
newarray(nmcnt) = nm
nmcnt = nmcnt + 1
' *** Write array of new members back to document and save it
If updated = True Then
Call doc.ReplaceItemValue("Members", Fulltrim(newarray))
Print "Updating " & doc.GetItemValue("Listname")(0)
Forall dm In delmembers
removelog(doc.GetItemValue("Listname")(0)) = removelog(doc.GetItemValue("Listname")(0)) & dm & ";"
Set doc = view.GetNextDocument(doc)
' *** We are all done
mailtext = ""
Forall rl In removelog
Call uidoc.FieldAppendText("LogResult", "Group '" & Listtag(rl) & "':" & Chr$(10))
mailtext = mailtext & "Group '" & Listtag(rl) & "':" & Chr$(10)
userarr = Split(Cstr(rl),";")
Forall u In userarr
Set user = New NotesName(u)
Call uidoc.FieldAppendText("LogResult", user.Common & Chr$(10))
mailtext = mailtext & user.Common & Chr$(10)
' Call uidoc.FieldAppendText("LogResult", Chr$(10))
Set mail = New NotesMail()
mail.MailTo = session.CommonUserName
mail.Subject = "[Notification] - Users removed from NAB"
mail.Principal = "IT Programs"
Msgbox "Done removing specified user(s) from Domino Directory.",64,"Finished"
Code snippet – jQuery
Sat, Mar 15th 2014 11:43a Karl-Henry Martinsson This morning I was working on a web application, and I came up with a pretty neat and simple little solution. So I just wanted to share it, in case anyone else need something similar.
I have a webpage with an HTML form. Each input tag has an attribute called notesfield, matching the name of the field in Notes where the value is stored:
Then I created a simple function that will call an agent on the Domino server, which will return all th [read] Keywords: agent
Connect 2014 – Day 0 (Saturday)
Mon, Jan 27th 2014 6:03a Karl-Henry Martinsson After not hearing the alarm this morning and therefore missing my original flight from DFW to MCO (Orlando International), I got booked on the next flight. I was in the air just a couple of hours late, and arrived at Dolphin in time for BALD at Big River on the Boardwalk. Had a great time connecting with friends after a year of not seeing many of them. Of course I got a hug from Mat Newman, meaning that IBM Connect started for real.
Låter I was going to hit ESPN, but due to changes there, [read] Keywords: ibm
Connect 2014 – My preliminary schedule
Wed, Jan 15th 2014 8:08a Karl-Henry Martinsson I have now created my preliminary schedule for Connect 2014. There are two only sessions that collide (on Tuesday), and I have not been able to find any repeats for them. That is how often has been at Lotusphere, but I would say that in the later years, the collisions have been fewer and fewer, thanks to more repeats and (perhaps) smarter scheduling.
Monday afternoon is when I have set time aside to visit the showcase and the labs. I also have a little bit of time after lunch Wednesday. As [read] Keywords: ibm
Pool party or no pool party, that is the question – or is it?
Mon, Jan 13th 2014 10:11a Karl-Henry Martinsson With the name change to Connect in 2013, the welcome reception/pool party changed somewhat. Instead of taking place at the pools/beach area between Swan and Dolphin, it started inside in the showcase area (Atlantic hall), and then moved outside for food, drinks and entertainment.
From what it looks like on the Connect 2014 website, and based on Chris Miller’s blog post, it sounds like the traditional poolside party is no more. The Connect website also only mention snacks and beverages.
[read] Keywords: atlantic
Connect 2014 – Survive the week!
Mon, Jan 6th 2014 7:02a Karl-Henry Martinsson Countdown to Connect 2014
In exactly 3 weeks, thousands of us will be sitting in the Northern Hemisphere ballroom at the Dolphin hotel in Orlando. We have already been involved in some social activities on Saturday with soccer, BALD and ESPN, followed by a full day of jumpstart and master class sessions on Sunday. Sunday evening there was the big welcome reception on the beach between Swan and Dolphin.
Some of us may have continued to Kimonos afterwards, or perhaps to Jelly Rolls dueling [read] Keywords: collaboration