In this blog I will show you can use OpenLDAP to lookup your Oracle Net (tnsnames) connections or AQ connection factories. Now you don't need to have an Oracle Internet Directory (OID) installed. The first step is to download openldap. Install this and download my
oracle.schema and put this in the schema folder of openldap. This file has to be included in the slapd.conf.
Edit slapd.conf and add
"include schema/java.schema" "include schema/oracle.schema" .Make sure anonymous can read the tnsnames entries.
access to dn="" by * readaccess to * by self write by users read by anonymous readWe have to configure the ldap for Oracle by making an OracleContext and oracledbconnections entry. 
I do this with ldapbrowser. You can
download it here. For this free java application I made some
templates which you can use.

Do the same for oracledbconnections ( this is for the AQ entries) Now use the queue template in ldapbrowser.

To make a tnsnames entry I select the OracleContext ldap entry and I use the orclNetService template to create a new Oracle connection.

We are ready to use it, we only has to create ldap.ora in the network\admin folder. The ldap.ora looks like this.
DIRECTORY_SERVERS= (localhost:389:636)
DEFAULT_ADMIN_CONTEXT = "o=sgi,c=us"
DIRECTORY_SERVER_TYPE = OID
We start sqlplus and use the ldap name as tnsnames entry. I can also start net manager and go the Directory menuitem to see our ldap entry

The second part shows you can lookup an AQ connection factory with JNDI and ldap. first let's register a new connection in the ldap server. For this I only need the following jars files. jndi-1.2.1.jar,jta-1.0.1.jar, jms-1.1.jar,aqapi.jar and the jdbc jar of oracle
package jms2;
import java.util.Hashtable;
import java.util.Properties;
import javax.jms.JMSException;
import javax.naming.Context;
import oracle.jms.AQjmsFactory;
public class register_jms_to_oid {
public register_jms_to_oid() {
Hashtable env = new Hashtable(5, 0.75f);
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://localhost:389");
env.put("server_dn", "o=sgi,c=us");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "o=sgi,c=us");
env.put(Context.SECURITY_CREDENTIALS, "secret");
String url = "jdbc:oracle:thin:@XPCND7010XMP:1521:orcl";
Properties properties = new Properties();
properties.setProperty("user","scott");
properties.setProperty("password","tiger");
try {
AQjmsFactory.registerConnectionFactory(env, "scott3", url ,properties, "queue");
} catch ( JMSException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
register_jms_to_oid register_jms_to_oid = new register_jms_to_oid();
}
}
Now we can lookup this entry with standard jms calls.
package jms2;
import java.util.Hashtable;
import javax.jms.JMSException;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.TextMessage;
import javax.jms.QueueConnectionFactory;
import javax.naming.Context;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
import javax.naming.NamingException;
public class lookup_jndi_queue {
private QueueConnection connection = null;
private QueueSession session = null;
private QueueSender sender = null;
public lookup_jndi_queue() {
Hashtable env = new Hashtable(5, 0.75f);
DirContext ctx;
QueueConnectionFactory queueConnectionFact;
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://localhost:389");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "o=sgi,c=us");
env.put(Context.SECURITY_CREDENTIALS, "secret");
try {
ctx = new InitialDirContext(env);
ctx = (DirContext)ctx.lookup("cn=connections, o=sgi,c=us");
Object reference = ctx.lookup("cn=scott");
queueConnectionFact = (QueueConnectionFactory)reference;
try {
connection = queueConnectionFact.createQueueConnection();
session = connection.createQueueSession(true, QueueSession.CLIENT_ACKNOWLEDGE);
connection.start();
QueueSession session = connection.createQueueSession(true, QueueSession.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue("JMS_IN");
sender = session.createSender(queue);
String xmlData = "1111";
TextMessage message = session.createTextMessage(xmlData);
sender.send(message);
session.commit();
} catch (JMSException e) {
// TODO
e.printStackTrace();
}
} catch (NamingException ee) {
// TODO
ee.printStackTrace();
}
}
public static void main(String[] args) {
lookup_jndi_queue lookup_jndi_queue = new lookup_jndi_queue();
}
}
You can also use the ldapbrowser template. The entry look this in ldap.