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
Create a new Naming Context in the configuration TAB. I choose “dc=databaseconnextion,dc=com” as new naming context
Enable this new Naming Context to store Oracle Databases net Services
Move to the OUD data Browser and Select the OracleContext entry in the dc=databaseConnect,dc=com Naming Context created above.
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.
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=184.108.40.206 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: 220.127.116.11 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.