Skip to main content
FORUM PLAN UPDATE: Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.
Information Mgmt
New to Lotus
How to buy
Live demos
Technical library
Forums & community
Java™ technology
Open source
SOA and Web services
Web development
My developerWorks
About dW
Submit content

developerWorks  >  Lotus  >  Forums & community  >  Notes/Domino 6 and 7 Forum

Notes/Domino 6 and 7 Forum



Sign in to participate PreviousPrevious NextNext

RE: Why not share your code?
Kings Fern 23.Feb.18 02:25 AM a Web browser
Applications Development 7.0.3 FP1 Linux on zSeries

OK Carl, along with the (ReadAttachmentJava) agent code that you had shared by those links, here is my code:

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
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
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"
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"
MsgBox "User is NOT a Member of ICADEV BlueGroups"
'If user is not member then redirect page to Authentication Failure screen
Print "[]"
End If

Exit Sub

MsgBox "WQO agent error on line = " & Erl & " with msg = " & Error$
End Sub

Read attachment without extracting?... (Kings Fern 19.Feb.18)
. . RE: Read attachment without extract... (Michael D. Zens... 20.Feb.18)
. . . . RE: Read attachment without extract... (Kings Fern 21.Feb.18)
. . RE: Read attachment without extract... (Carl Tyler 20.Feb.18)
. . . . RE: Read attachment without extract... (Stan Rogers 20.Feb.18)
. . . . . . RE: Read attachment without extract... (Kings Fern 21.Feb.18)
. . . . . . . . RE: Read attachment without extract... (Stan Rogers 21.Feb.18)
. . . . . . . . . . RE: Read attachment without extract... (Kings Fern 23.Feb.18)
. . . . RE: Read attachment without extract... (Kings Fern 21.Feb.18)
. . . . . . Why not share your code? (Carl Tyler 21.Feb.18)
. . . . . . . . RE: Why not share your code? (Kings Fern 23.Feb.18)

Document Options

  Document options
Print this pagePrint this page

Search this forum

Forum views and search

  Forum views and search
Date (threaded)
Date (flat)
With excerpt
Advanced search

Sign In or Register

 Sign In or Register
Sign in
Forgot your password?
Forgot your user name?
Create new registration

Member Tools

RSS Feeds

 RSS feedsRSS
All forum posts RSS
All main topics RSS
More Lotus RSS feeds


Forum use and etiquette
Native Notes Access
Web site Feedback

Lotus Support

 Lotus Support
IBM Support Portal - Lotus software
Lotus Support documents
Lotus support by product
Lotus support downloads
Lotus support RSS feeds


IBM Composite Applications
IBM Mashup Center
IBM Connections
IBM Connections Cloud Developers
IBM Docs
IBM Forms
IBM Mobile Connect
IBM Sametime
IBM SmartCloud for Social Business
IBM Web Experience Factory
Lotus Domino
Lotus Domino Designer
Lotus Expeditor
Lotus Foundations
Lotus iNotes
Lotus Instructor Community Courseware
Lotus Notes
Lotus Notes & Domino Application Development
Lotus Notes Traveler
Lotus Protector
Lotus Quickr
Lotus Symphony
IBM Web Content Manager
WebSphere Portal

Lotus Forums

 Lotus Forums
Notes/Domino 9.0
Notes/Domino 8.5 + Traveler
Notes/Domino XPages development forum
Notes/Domino 8
Notes/Domino 6 and 7
IBM Connections
IBM Mobile Connect
IBM Sametime
IBM SmartCloud Notes
Lotus Enterprise Integration
Lotus Protector
Lotus Quickr
Lotus SmartSuite