GetDocumentByKey on Remote Server

Is the method GetDocumentByKey supported when the database the lookup is performed is a remote server?

I am issuing the command below from a JS agent which look for a document in another database on a remote server.

Set notesDocument = notesView.GetDocumentByKey( “1200”, True )

The server the Agent runs on and the remote server trust each other’s.

I can read the Notes view name (notesView.Name), but notesDocument is always Nothing.

The Agent is signed with my Notes ID and using my name to list the ACL enties I have in the remote database, it confirms that I have access to the remote database and its content.

Has another person experienced the same problem?

Thanks,

Serge

Subject: GetDocumentByKey on Remote Server

Serge,

Stupid question here, but is the value you are using as a key a string or number value? if you a feeding a string to the key, but the key wants a number, it will never return a document.

I am assuming that your line there is grabbed directly from your script. I would check what kind of data values your sorted view is expecting.

hth.

brandt

Subject: RE: GetDocumentByKey on Remote Server

Hi Brandt,

Yes, the first column of the view points to a field that is declared as String and that contains strings (text). The column also sorted.

Thanks,

Serge

Subject: RE: GetDocumentByKey on Remote Server

Serge,

okay, another dumb question…you said the servers have rights to the other servers. but does the server you are calling the agent from have access rights to the remote DB? it almost sounds like the remote db has a default access level of Reader with the ability to view public documents…that way, it could see the view, but not the docs contained therein…

just throwing stuff against a wall to see what sticks.

brandt

Subject: RE: GetDocumentByKey on Remote Server

Brandt,

I am the author of the calling agent and I have developer access (role [Developer]) on all databases on both servers.

Now, you are talking about server’s right, isn’t it that if I can get a handle to the remote database and to one of its view, then the server must surely have the right of access to the other server or to that remote database at least?

But you might be on the right track as the view does not have any security on it, but the db has. Its ACL has “No Access” for Default and Anonymous.

The document I am trying to access has a $Reader field that contains the role [Developer].

What is really weird is that if I use GetDocumentByUNID and hard code the unique ID of the document, the sever the agent runs on crashes.

Serge

Subject: RE: GetDocumentByKey on Remote Server

Serge,

Are you running it on a schedule? Even if you saved and signed the agent, when you run it, it is still the SERVER running the agent. If it doesn’t have access to the DB, but Default has access to public docs, then you would be able to see the view, but the view would appear to have no docs in it.

Brandt

Subject: RE: GetDocumentByKey on Remote Server

Brandt,

No, it is triggered by an anonymous HTTP request (?OpenAgent) and “Run as web user” is not ticked, that is why I think the agent runs with my credential as I am the writer/signer of the agent.

Are you saying that still the agent runs as if it was signed with the server’s ID?

Read/Write public document is not ticked for either Default nor Anonymous on then remote db.

Serge

Subject: RE: GetDocumentByKey on Remote Server

Serge,

I found this in the notes help…perhaps the web agent isn’t running as the signer but instead as a default user?

From the Notes client or the Web

Agents run in the Notes client or on the Web based on the effective user. The effective user is the user under whose authority the agent runs. The effective user depends on the environment in which the agent runs.

Agent type Effective user

Notes client agent Current user ID

Web agent One of the following:

Current Web user

Agent signer (agent owner)

On behalf of (set in the Security tab of the Agent Properties box).

Scheduled agent Either:

Agent signer (agent owner) 

On behalf of (set in the Security tab of the Agent Properties box).

When a user runs an agent from the Notes client, the agent runs with the rights of the effective user, which is the current User ID.

When a Web user runs an agent, the agent also runs using the rights of the effective user and Domino checks the effective user’s rights to access the database. However, you can set up the agent so that Domino checks the invoker’s rights to access the database instead of the effective user’s rights. Checking the invoker’s rights can provide more security.

To specify that Domino verify the invoker’s access to the database, follow these steps:

  1. Double-click an agent name in the agent list.

  2. Click the Security tab.

  3. Check “Run as Web user.”

When “Run as Web user” is checked, Domino prompts Web users for their name and password when they attempt to run the agent. Domino uses the login information to check for the invoker’s rights in the database ACL.

I also found this:

If the OpenAgent URL command starts an agent, there is no current document, but DocumentContext and getDocumentContext return a special NotesDocument or Document object containing the values of the CGI variables supported by Lotus Domino. In the case of RunAgent or ToolsRunMacro, CGI values are available but not automatically. The form backing up the current document must contain a field named after each desired CGI variable.

Could this have something do with it? I rarely run agents from the web…

brandt

Subject: RE: GetDocumentByKey on Remote Server

Thanks Brandt,

This confirms what I expected and knew.

The agent runs as " Agent signer (agent owner)".

I will try another couple of thinks and add that here.

Serge

Subject: RE: GetDocumentByKey on Remote Server

Obviously, you must have checked all that I list below, but I’ll still mention them.

  1. Try False as the second parameter in the method and see if anything is returned.

  2. Readers field. Do you have access to the target document?

  3. Trim the value that is being displayed in the key column.

Subject: GetDocumentByKey on Remote Server

The answer to your question is Yes, it is supported.

If it were me, I would make a simple db on the local server and make sure that works, then copy the db to the foreign server. That way, you eliminate easy errors.

regards,

raphael

Subject: RE: GetDocumentByKey on Remote Server

Raphael,

I thought about that, but I am so 100% that it will work that I did not bother testing it.

But I think that it would not hurt anyway and will try it.

Serge

PS.

What is really weird is that if I use GetDocumentByUNID and hard code the unique ID of the document, the sever the agent runs on crashes.