3

I have a database that I can connect to using jdbc using the string "jdbc:oracle:thin@ldap://SERVER_NAME:1234/SERVICE,cn=OracleContext,dc-world".

However, when I use node-oracledb, this connection string does not work, presumably because Node doesn't use jdbc. What connection string could I use to connect to the database?

Christopher Jones
  • 9,449
  • 3
  • 24
  • 48
mrcool
  • 55
  • 1
  • 6

2 Answers2

2

There is no "Easy Connect" syntax available for LDAP so you will need to configure ldap.ora and sqlnet.ora files and use a non-Easy Connect string alias in node-oracledb (or in other tools like SQL*Plus, PHP OCI8, Python cx_Oracle, Golang godror etc).

I'm told (!) the steps are:

  1. Invoke netca -> Directory Usage

  2. Configure naming to use LDAP by netca->Naming Methods Configuration. This sets up sqlnet.ora for name lookup.

  3. run netmgr to setup the entry in ldap or Enterprise Manager to setup ldap.

  4. Copy those files to a subdirectory on the machine where you run Node.js, and set TNS_ADMIN to the directory containing the files. With Instant Client you can put it in the network\admin subdirectory under the Instant Client libraries. See the manaul entry Optional Oracle Net Configuration

  5. Set node-oracledb's connectString to the connect alias configured in 3, e.g. "orcl"

Christopher Jones
  • 9,449
  • 3
  • 24
  • 48
  • netca seems to be a linux only tool and unfortunately I'm running windows. is there anyway you or someone could post a sample generated by these tools? that would be very helpful. Also, this seems to be a common problem when migrating from Java to node. Has oracle said anything about supporting the LDAP style connection strings? – dalcantara Nov 08 '16 at 11:42
  • netca is not linux only, works on windows. install oracle database and it comes with it by default. – Shahid Roofi Khan Jul 07 '21 at 10:43
1

In order to get an ldap connection to work, I had to do the following:

In the network/admin folder of the oracle client add (These were provided by my db admin, but there are examples here:):

  • LDAP.ORA
  • sqlnet.ora

And then the connectString is just the service name and nothing else. So, using the original example jdbc:oracle:thin@ldap://SERVER_NAME:1234/SERVICE,cn=OracleContext,dc-world the connectString would just be SERVICE

FoxShaunR
  • 33
  • 7