I am calling an agent from an XPage via SSJS:
importPackage(java.net);
importPackage(java.io);
var protocol = context.getUrl().getScheme();
var host = context.getUrl().getHost();
var url = protocol + "://" + host;
var path = env["dir_path"];
var dbName = datasource["db_app_filepath"];
var agentRef = "response?OpenAgent";
var paramName = "custId";
var urlAgent = url + "/" + path + dbName + "/" + agentRef;
var agent:URL = new URL(urlAgent);
var agentConnection:URLConnection = agent.openConnection();
var inputReader:BufferedReader = new BufferedReader(new InputStreamReader(agentConnection.getInputStream()));
var res:String="";
while ((inputLine = inputReader.readLine()) != null) {
res+=inputLine;
}
print("value form agent = " + res);
The agent just returns a simple string:
Option Public
Option Declare
Sub Initialize
Dim session As New NotesSession
Dim creator As String
creator = session.EffectiveUserName
Print "Hello World " + creator
End Sub
But in the print statement in the console I see that the login form is presented.
If I access the agent directly in a browser window I get as example returned:
Hello World CN=§Unrestricted §Signer/OU=System/O=ACME
This is the username which I have set in the Run on behalf of property in the agent.
On the XPage I am already authenticated.
Should I provide the credentials in my call or?
The idea behind the code is that I want to check if the user is not creating double entries for a type of object. The objects (Notes documents) have Readers restriction so user X may not see user Y's entries.