Hi,
I'm a beginner with JNDI and LDAP, and I'm trying to write a simple class that will connect a Notes database with a public LDAP server (directory.verisign.com). Here's the code I have (in a Notes agent):
====================================
import java.util.*;
import javax.naming.*;
import javax.naming.directory.*;
import lotus.domino.*;
//This is used to try and connect to LDAP to see if it is up.
public class JavaAgent extends AgentBase {
public void NotesMain() {
DirContext root = null;
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Agent currentAgent = agentContext.getCurrentAgent();
Database db = agentContext.getCurrentDatabase();
String ldapInitContext = "com.sun.jndi.ldap.LdapCtxFactory";
String ldapProviderURL = "ldap://directory.verisign.com:389/";
Hashtable environment = new Hashtable();
environment.put("java.naming.ldap.version", "2"
environment.put(Context.INITIAL_CONTEXT_FACTORY, ldapInitContext);
environment.put(Context.PROVIDER_URL, ldapProviderURL);
root = new InitialDirContext(environment);
//If we make it here then there was no Error so close the LDAP directory
root.close();
} catch(Exception e) {
e.printStackTrace();
}
}
}
==============================================
The code compiles, but always gives me a "connection refused" error in my debugger. Do I have a context property wrong? Do I need to add more properties, such as "SECURITY_PRINCIPLES" or "SECURITY_CREDENTIALS"? Can anybody give me code that will definitely work to connect to a public LDAP server, as a sanity check for what I'm doing?
Thanks in advance!
I'm a beginner with JNDI and LDAP, and I'm trying to write a simple class that will connect a Notes database with a public LDAP server (directory.verisign.com). Here's the code I have (in a Notes agent):
====================================
import java.util.*;
import javax.naming.*;
import javax.naming.directory.*;
import lotus.domino.*;
//This is used to try and connect to LDAP to see if it is up.
public class JavaAgent extends AgentBase {
public void NotesMain() {
DirContext root = null;
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Agent currentAgent = agentContext.getCurrentAgent();
Database db = agentContext.getCurrentDatabase();
String ldapInitContext = "com.sun.jndi.ldap.LdapCtxFactory";
String ldapProviderURL = "ldap://directory.verisign.com:389/";
Hashtable environment = new Hashtable();
environment.put("java.naming.ldap.version", "2"
environment.put(Context.INITIAL_CONTEXT_FACTORY, ldapInitContext);
environment.put(Context.PROVIDER_URL, ldapProviderURL);
root = new InitialDirContext(environment);
//If we make it here then there was no Error so close the LDAP directory
root.close();
} catch(Exception e) {
e.printStackTrace();
}
}
}
==============================================
The code compiles, but always gives me a "connection refused" error in my debugger. Do I have a context property wrong? Do I need to add more properties, such as "SECURITY_PRINCIPLES" or "SECURITY_CREDENTIALS"? Can anybody give me code that will definitely work to connect to a public LDAP server, as a sanity check for what I'm doing?
Thanks in advance!