OK Carl, along with the (ReadAttachmentJava) agent code that you had shared by those links, here is my code:
%REM
Agent VerifyUser
Created Feb 5, 2018 by Kingsley E Fernandes-1/India/IBM
Description: Agent to Verify user logged in to ICA is a member of BlueGroups for ICA
%END REM
Option Public
Option Declare
Use "BluePages"
Sub Initialize
On Error GoTo ErrHandle
Dim s As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim coll As BPResults
Dim bpd As BluePages
Dim curUser As NotesName
Dim dbProfileView As NotesView
Dim dbProfileDoc As NotesDocument
Dim userEmail As String
Dim BlueGroupsURL As String
Dim url As String
Dim webDoc As NotesDocument
Dim strEncodedUser As String
Dim FileToRead As String
Dim item As NotesItem
Dim paramid As String
Dim agent As NotesAgent
Set doc = s.Documentcontext
Set db = s.Currentdatabase
'Fetch the BluePages API URL from the Global Configuration Doc
Set dbProfileView = db.Getview("GlobalConfigView")
Set dbProfileDoc = dbProfileView.Getfirstdocument()
Set bpd = New BluePages(dbProfileDoc.EdDirURL(0))
If Not bpd.IsOpen() Or bpd.GetReturnCode() <> 0 Then
MessageBox "Error in connecting to BluePages API",, "Error"
Exit Sub
Else
MessageBox "Connected to BluePages API"
End If
'Get the Current logged in user from the CGI variable Remote_User
Set curUser = New NotesName(doc.Remote_User(0))
MsgBox "In WQO agent: User logged in is " + doc.Remote_User(0) + " Abbv Name = " & curUser.Abbreviated + " Canon = " & curUser.Canonical
strEncodedUser = curUser.Canonical
strEncodedUser = Replace( strEncodedUser, " ", "+")
strEncodedUser = Replace( strEncodedUser, "=", "%3D")
strEncodedUser = Replace( strEncodedUser, "/", "%2F")
MsgBox "Encoded User ID = " & strEncodedUser
'Set coll = bpd.GetPersonsByNotesID("CN%3DKingsley+E+Fernandes-1%2FOU%3DIndia%2FO%3DIBM%25")
Set coll = bpd.GetPersonsByNotesID(strEncodedUser)
If coll.succeeded() Then
MsgBox "BP message = " & coll.GetErrorMessage() & " code = " & coll.GetReturnCode() & " col rows = " & coll.Rows() 'If the query completed normally,
If coll.rows() = 0 Then 'No records found
Msgbox curUser.Abbreviated & " was not found." & coll.GetColumn("name")
ElseIf coll.rows() >= 1 Then ' coll.rows()>=1 ...and found at least one name,
Msgbox "Name: " & coll.GetColumn("NAME")(0) & " EMAIL = " & coll.GetColumn("INTERNET")(0)
End if
End If
userEmail = coll.GetColumn("INTERNET")(0)
MsgBox "To verify " & userEmail & " in ICA BlueGroups"
'Fetch the BlueGroups Validation URL from Global Configuration doc & append the email of user to validate
BlueGroupsURL = dbProfileDoc.EdBlueGroupsURL(0)
url = BlueGroupsURL & userEmail
'Fetch the BlueGroups validation webpage which will return the user's membership results in an attached file called groupsxml.wss
Set webDoc = db.GetDocumentByURL(url,1)
FileToRead = "groupsxml.wss"
Set item = webDoc.AppendItemValue("Filename", FileToRead)
Set item = webDoc.AppendItemValue("UniversalID", webDoc.UniversalID)
Call webDoc.Save(True, False)
'Set the parameter value of the web document which has file to read
paramid = webDoc.Noteid
Set agent = db.GetAgent("(ReadAttachmentJava)")
'Start agent and pass note ID of document
'Use agent.RunOnServer(paramid) to run the agent on the server
If agent.RunOnServer(paramid) = 0 Then
MsgBox "Agent ran - Success"
Else
MsgBox "Agent did not run - Failure"
End If
'Delete in-memory document. This is necessary because we need to reload
'the document in order to get the latest data which the Java Agent has
'written into the parameter document
Delete webDoc
'Get the result from the parameter document (the data from the file attachment)
Dim theResult As String
Set webDoc = db.GetDocumentByID(paramid)
theResult = webDoc.Result(0)
'Do whatever you need with the data
'Your code goes here
MsgBox "ATTACHED FILE DATA = " & theResult
'When finished delete the temporary parameter document
Call webDoc.RemovePermanently(True)
'If the return code ZERO is present in that File Data then user is a member of ICA BlueGroup
If InStr( theResult , "<rc>0</rc>") <> 0 Then
MsgBox "User is a Member of ICADEV BlueGroups"
Else
MsgBox "User is NOT a Member of ICADEV BlueGroups"
'If user is not member then redirect page to Authentication Failure screen
Print "[
https://a25zeidb0251g.pok.dst.ibm.com/tools/forms/ica/icaweb.nsf/loginerr]"
End If
Exit Sub
ErrHandle:
MsgBox "WQO agent error on line = " & Erl & " with msg = " & Error$
End Sub