How do you connect to an LDAP server using node-oracledb? - oracle

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?

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:
Invoke netca -> Directory Usage
Configure naming to use LDAP by netca->Naming Methods Configuration. This sets up sqlnet.ora for name lookup.
run netmgr to setup the entry in ldap or Enterprise Manager to setup ldap.
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
Set node-oracledb's connectString to the connect alias configured in 3, e.g. "orcl"

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

Related

Need to Connect by Proxy with ODP.NET Using My Certificate

I'm having an issue making a proxy database connection to an ORACLE database using ODP.net. I need my program to attempt the proxy connection but then prompt me for my certificate and authenticate me with that.
I have a Perl script that does this and it only requires me to specify the name of the TNS entry and the user I want proxying in for me.
I also have my SQL Developer doing the same thing, pointing to the same TNS entry.
But when I try to attempt the same approach with ODP.NET it just gives me the ORA-12154 error, "TNS: Could not resolve the connect identifier specified."
From my limited knowledge of Oracle I ASSUME that the error means that it couldn't find that TNS entry. And I've verified that the entry DOES exist in my tnsnames.ora file and proved I could proxy to it via my Perl script and SQL Developer. Even put a breakpoint in my VB code to ensure I was specify the correct TNS Entry.
I've even stripped down the connection string to JUST the datasource to see what error I get. So I'm not sure if I have the connection string wrong or if it needs to be in a different format. But I DO know that the solution HAS to allow me to specify the TNS alias and the connection HAS to prompt me for my certificate. No password.
So I guess I'm trying to find out what the appropriate connection string would look like to do this and why .NET can't seem to figure out what this TNS alias is.
I've tried setting the USER ID attribute to the account I want proxying for me, set the PROXY USER ID attribute the same way as well as also tried "/", set the DATA SOURCE attribute to the TNS alias.
This program will be deployed to four different environments that have the same TNS alias in them but point to different servers. So I really need to be able to specify the TNS alias.

Oracle instant client 12c EZConnect Using tcps instead of tcp

I download oracle instant client 12.2.0.1.0, I try to use sql loader to load csv data to the database. I can successfully load using following:
sqlLdr.exe userid=user/password#//192.9.200.228:1521/oracle ERRORS=4000 control=D:\temp\csma\xx_20190225.ctl log=D:\temp\csma\xx.log
However my production would only allow secured connection only (use tcps), can I use tcps by EZConnect? If not how can I connect using tcps using just the instant client (not full client)?
Instant Client based applications can connect using a Net Service Name from a tnsnames.ora file. The Instant Client installation instructions (eg. the instructions for Linux x64) tell you where to put the Oracle Net configuration files. Create the default location, put the files there, and update the connect string in your application.
With Oracle 19c, the Easy Connect syntax was extended to be 'Easy Connect Plus' so you specify things like the wallet location in-line, see the Understanding the Easy Connect Naming Method in the Oracle Net 19c documentation. No Instant Client 19c has been released yet.

Export Database connection to Oracle Developer

I have a database Connection established in odbcad and Microsoft Access (aswell as working in Excel) via ODBC and want to also get it working in Oracle SQL developer.
It is a Windows SQL Server as far as i know and I have tried several Settings, of which None works. I have also installed Driver for ODBC. I would like to Import Settings into SQL developer as applied in MS Access, is there any possibility?
No, SQL Developer is a Java application and uses a JDBC driver.
But if you look at the odbc properties for your connection, those should largely translate to what you need to define a basic connection.
Oracle:
Server name or IP address of the DB, port # for the listener, and the name of the SID or Service, plus a valid username and password is all you need to connect to Oracle.
What error do you get when you try to connect?
Show us what you're trying.
Update:
You're trying to connect to SQL Server but you're getting"
Native SSPI library not loaded
You're trying to use OS Authentication for your connection. For this to work with the jTDS driver, you need to copy a DLL file named ntlmauth.dll (which is for NT authentication) under the jtds-x.x.x-dist\x86\SSO\ or jtds-x.x.x-dist\x64\SSO\, to any directories in the PATH environment.
Please update your question such that's it's clear you're connecting to SQL Server and share the error message so others can find it.
I imagine this question is a duplicate of many previous iterations of the same challenge.

exp command accepts host and port to export remote DB tables

In oracle we have exp utility. we use that as exp username/password#database. Here can we use provide host and port details to export to remote db tables? If yes, what is the format to provide those? Thanks
You can use an alias from your tnsnames.ora, or provide a connection string in a similar format, or use the Easy Connect syntax:
exp user/password#host:port/service_name
Note that this requires the service name of the database, which might not be the same as the SID. You can get the services by running lsnrctl services on the remote server (if you can) or by querying the v$parameter view (if you have access and permission), or by asking the DBA for the remote server.
The connection options are the same as for any other tool, so if you can connect to the remote database using SQL*Plus then you can use the same connect string for exp. If you're using #database to connect to a local instance then that is probably already defined in your tnsnames.ora, and you could add entries for the remote database there too. If this is a one-off then the Easy Connect is simpler.
Also, if you're not still on an old version (pre-10g), you should use datapump (expdp) rather than the old exp tool.

jdbc using sqlnet.ora

I have a program that wants to make a connection to an oracle database on our network. This program is written in java and has to use jdbc. Our PC's are setup to use sqlnet.ora files to determine the order of how to resolve. All our PC's first check ldap (which the ldap file is on all these PC's pointing to the ldap server) and then secondly to use tnsnames.ora file, but this file is empty now so basically I want to use ldap, but do it via sqlnet.ora. Any ideas what the connection would look like for the url parameter?
From the JDBC Developer's Guide
The oracle.net.tns_admin system property must be set to the location of the tnsnames.ora file so that the JDBC Thin driver can locate the tnsnames.ora file. For example:
System.setProperty("oracle.net.tns_admin", "c:\\Temp");
String url = "jdbc:oracle:thin:#tns_entry";
DriverManager.getConnection(url, ...);
Because of the system property, the thin driver is able to locate the tnsnames.ora file and thus can resolve the TNS name specified in the URL. Because the thin driver is usually intended to work without an Oracle client installation, this is not enabled by default.
As far as I remember, you only need tnsnames.ora, you don't need an Oracle client when using the thin driver even when specifying a TNS name.
If your program does not allow setting system properties you have two options:
Specify it when starting your program java -Doracle.net.tns_admin=c:/foobar ...
Set an environment variable JAVA_TOOLS_OPTIONS that contains -Doracle.net.tns_admin=c:/foobar. That will then be picked up by any Java program automtically
From the Oracle JDBC FAQ
jdbc:oracle:oci:#<<TNS alias>>
where <<TNS alias>> is the LDAP entry that you would use if you were connecting via, say, SQL*Plus

Resources