Infrastructure at your Service

Pascal Brand

How to declare TNS entries in Oracle Unified Directory (OUD)

Using a LDAP server to store the TNS connection strings can be a single point of declarations for all client tools. Note that it can be a single point of failure too, thus, a High Availability LDAP configuration is recommended for production use. In my case, I was interested in using a LDAP as TNS connections repository for the WebLogic Domains Data-Source connections. I used a Oracle Unified Directory (OUD).

The first step is to enable the Oracle Database Net Services in OUD. I choose to create a new Naming Context to isolate the TNS declarations from the users and groups.

Connect to the OUD
Connect to the OUD instance

Create a new Naming Context in the configuration TAB. I choose “dc=databaseconnextion,dc=com” as new naming context
Creating a new Naming Context

Enable this new Naming Context to store Oracle Databases net Services
Enabling the New Naming Context for Database Net Services

Move to the OUD data Browser and Select the OracleContext entry in the dc=databaseConnect,dc=com Naming Context created above.
OUD data browser This OrcaleContext entry has been created automatically and at the same time, some policies were created to allow queries in this OracleContext to anonymous users.

Create a TNS entry to point to the DB. This is done creating a new entry and selecting the orclNetService object class in the first wizard.
Create New TNS entry
New TNS Entry: give a name
New TNS entry: fill up the attributes
New TNS entry: select the Attribute used in the DN
New TNS Entry: Summary
New TNS Entry: The ORCL entry once created.

Test if the TNS connection resolution is reachable using a LDAPSEARCH request:

[[email protected] ~]$ /u00/app/oracle/product/12.1.0/dbhome_1/bin/ldapsearch -h vm01 -p 1389 -b dc=DatabaseConnection,dc=com cn=orcl
cn=orcl,cn=OracleContext,dc=databaseconnection,dc=com
orclNetDescString=(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)   (HOST = vm02.dbi-workshop.com)(PORT =1521))) (CONNECT_DATA = (SID = ORCL)))
orclVersion=12.2.0.4
cn=orcl
objectClass=top
objectClass=orclNetService
orclNetDescName=ORCL Demonstration DB

Of course once the new Naming Context has been created and the Oracle Net Services enabled in it, the same TNS entry can be created using a ldif file.

[[email protected] ~]$ more orcl.ldif
dn: cn=orcl,cn=OracleContext,dc=databaseconnection,dc=com
objectClass: top
objectClass: orclNetService
orclNetDescString: (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)   (HOST = vm02.dbi-workshop.com)(PORT =1521))) (CONNECT_DATA = (SID = ORCL)))
orclVersion: 12.2.0.4
cn: orcl
orclNetDescName: ORCL Demonstration DB
[[email protected] ~]$ ldapadd -h vm01 -p 1389 -D "cn=Directory Manager" -w ****** -f orcl.ldif
adding new entry cn=orcl,cn=OracleContext,dc=databaseconnection,dc=com

[[email protected] ~]$

Now that we have our LDAP server configured to store TNS connections, the following blog will explain how to configure a WebLogic JDBC Datasource to resolve the database connection using an LDAP definition.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Pascal Brand
Pascal Brand

Senior Consultant & Middleware Technology Leader