Read Domino Address book info

this is my code and i would like to know what else i setting i need to do, in order to read the address book information, which the Lotus Notes is installed in another pc?

import lotus.domino.*;

import java.io.PrintWriter;

public class ReadAddress extends AgentBase

{

//NotesMain method is the entry point for Domino Java Agent

public void NotesMain()

{

	try

	{

		//Create a Session object

 		Session s = this.getSession();

 		// PrintWriter object is used for output

 		

 		PrintWriter pw = this.getAgentOutput();

 		//Create a Database object; we will use the name and address book

		Database db = s.getDatabase("","names.nsf");

		//Continue only if the database was properly instantiated

		if (db != null)

		{

			//create a View object using the list of people in the NAB

			View vw = db.getView("People");

			//Continue only if the View object has been properly instantiated

			if (vw != null)

			{

				//Retrieve the first document in the view

				Document doc = vw.getFirstDocument();

				//Declare String objects to be used for field values

				String fname = null;

				String lname = null;

				int c = 0;

				//Loop through all documents in the view;

				while (doc != null)

				{

					c += 1;

					//Retrieve the contents of the FirstName and lastname field as a String

					fname = doc.getItemValueString("FirstName");

					lname = doc.getItemValueString("LastName");

					//display name and counter variable

					pw.println("Person #" + c + " : " + fname + " " + lname);

					//Get next document from the view

					doc = vw.getNextDocument(doc);

				}

				//return memory used by the View object to the system

				vw.recycle();

			}

			//Return memory used by the Database object to the system

			db.recycle();

		}

		//Return memory used by the Session object to the system

		s.recycle();

	} 

	catch(Exception e) 

	{

		e.printStackTrace();

	}

}

}

Subject: RE: Read Domino Address book info

Are you trying to access the server copy of the NAB? If it is the server copy then you need to fill in the servername.

Database db = s.getDatabase(“myservername”,“names.nsf”);

Subject: RE: Read Domino Address book info

U mean the computer name where my Domino Admin installed or the computer name of which the user’s account who i would like to read the address book exist?

should i need to include the following of code before i call the RunNotes function to do all the DIIOP setting?

DiiopAccess diiop = new DiiopAccess();

        diiop.setServer(config.getDiiopHost());

        diiop.setPort(config.getDiiopPort());

        diiop.setUsername(user);

        diiop.setPassword(pass);

        diiop.openSession();

Subject: RE: Read Domino Address book info

I was referring to the Domino server name. What is the objective of your code? To access the local replica copy of the user’s address book or the serve copy of Domino Directory?

Subject: RE: Read Domino Address book info

my objective is to access the local replica copy of the user’s address book

Subject: RE: Read Domino Address book info

I see. Pretty much okay for your code. Typical NAMES.NSF is installed in the default Data folder, hence should be okay for that line of code.

On the DIIOP, sorry pal, I have no experience to advise you further :slight_smile:

Subject: RE: Read Domino Address book info

hi,Thks for your reply, besides the first name and last name, what else i can read from the address book, if possible, pls provide me with lines of codes,

fname = doc.getItemValueString(“FirstName”);

my current version of the NCSO.jar don’t have the agentBase class, can u pls tell me where can i get the NCSO file that come with the agentBase class?

in order to read user address book, should i need to specify the computer name as u mentioned before?

Subject: RE: Read Domino Address book info

my objective is to access the local replica copy of the user’s address book, where my program is running on another machine, which don’t have the Lotus Notes 6.5 installed, so should i need to specify the computer name of the machine where the user’s address book exists?

Subject: RE: Read Domino Address book info

No way – Notes needs to be installed on the machine running the code, unless the remote machine is a Domino server with the DIIOP task running (the local version of the server, if installed, is only available to localhost). The Notes/Domino Java “classes” are wrappers around native code, and that code can be invoked locally by autheniticating with the user’s ID file using the Notes client executables, or by authenticating with a server using Domino’s HTTP authentication scheme.

As for your AgentBase question, that only applies to Notes/Domino agents (code that is part of a Notes database), not to external code.

Subject: RE: Read Domino Address book info

yes, the remote machine is a Domino server with the DIIOP task running. In such a case, should i need to set the DIIOP host IP, DIIOP port and the agent user before i call the RunNote function is it?

Sorry, i not really understand about the answer given for the AgentBase