I’m working on a project where I need to automate user and mail file deletion. (We are handling 15 000 student accounts so anything manual isn’t feasible.)
My plan to solve this is in two parts. Like this.
First I create an adminp job that removes the user (with DeleteUser). I get the note id for the created job as a return value. I use that id to get a handle on the job in the admin4 database. I then mark the document with a special flag field (‘ORG-flag’ in the example below). I do that so I can find the requests that my code has initiated.
Code fragment (from test code):
Set adminp = ses.CreateAdministrationProcess(“Acme/Server/ORG”)
nid = adminp.DeleteUser(user.GetItemValue(“FullName”)(0), True, 2, “”)
Set doc = adminDb.GetDocumentByID(nid)
Call doc.ReplaceItemValue(“ORG-flag”, “Y”)
Call doc.Save(False, False)
The second part of the solution is a scheduled agent that opens the admin4 database and checks the “Pending By Age” view. The agent checks for each document if it’s parent (as found in the ‘ProxyOriginatingRequestUNID’ field) has the flag field set (‘ORG-flag’). If the parent has the field set then agent checks if the request is of the right type (as defined in the ‘ProxyAction’ field). If it is, then the appropriate approve method of the NotesAdministrationProcess class is called.
Code fragment (from test code):
Set adminpDb = New NotesDatabase(“Acme/Server/ORG”, “admin4.nsf”)
Set adminp = ses.CreateAdministrationProcess(“Acme/Server/ORG”)
Set pending = adminpDb.GetView(“PAAByAge”)
Set nextDoc = pending.GetFirstDocument
While Not(nextDoc Is Nothing)
Set pendingDoc = nextDoc
Set nextDoc = pending.GetNextDocument(nextDoc)
parentUnid = pendingDoc.GetItemValue(“ProxyOriginatingRequestUNID”)(0)
Set parentDoc = adminpDb.GetDocumentByUNID(parentUnid)
If Not(parentDoc Is Nothing) Then
flag = parentDoc.GetItemValue("ORG-flag")(0)
action = pendingDoc.GetItemValue("ProxyAction")(0)
If flag = "Y" And action = "22" Then
nid = adminp.ApproveMailFileDeletion(pendingDoc.NoteID)
End If
End If
Wend
So. If there are any NotesAdministrationProcess experts out there. Is this solution OK, or has I overlooked something crucial? Any comments are appreciated.