I'm trying to open names.nsf in code. The piece of code has been working for a while but suddenly, I'm getting null. Any idea why? I don't seem to be getting any errors and I don't know how to work out what's wrong.
I can open the database from the Notes client on the same machine.
UPDATE
Here's the code. The fields are initialised in the constructor. The null reference occurs on the .IsOpen() message.
public class DominoPersonSearcher
{
private string _serverName;
private string _databaseFileName;
private string _password;
private Domino.NotesDatabase OpenDatabase(out Domino.NotesSession notesSession)
{
notesSession = new Domino.NotesSessionClass();
notesSession.Initialize(this._password);
Domino.NotesDatabase notesDatabase;
notesDatabase = notesSession.GetDatabase(this._serverName, this._databaseFileName, false);
if (!(notesDatabase.IsOpen))
{
notesDatabase.Open();
}
return notesDatabase;
}
This code is C# and runs on a web server; it's not inside a db - it's running outside of Notes, just calling into it. I've used this exact mechanism many times. It uses a .NET wrapper around the Lotus Domino Objects COM C:\notes\domobj.tlb called Interop.Domino.dll. Domino is installed on a different server.
Returning null from getdatabase means you could not access the database. If you're running this as a java agent then it will run under your privileges. A server can be configured to restrict who can access databases via agents on a server.
Try opening another database on the server that you have the same level of access to or a database you have manager access to. Doing this, checks to see if you can open databases via agents on the server. If you can't open this database either, then it sounds like a permission problem with the server. It's not the database itself, because you can access it via the Notes client.
One way around it, is that you can can also tell the agent to run under the server's ID. This usually gets around access issues. The agent's security options is the last tab, on the "agent properties" dialog box. Note that this option can also be controlled via server settings, and you'll get an error message if you're not allowed to do this either. Let me know how you go..