Skip to Main Content
  • Questions
  • connection string needed in .net using Oracle wallet

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Christine.

Asked: June 15, 2017 - 10:07 pm UTC

Last updated: June 16, 2017 - 1:29 am UTC

Version: 12.1.0.2

Viewed 1000+ times

You Asked

What kind of connection string is needed in .net when using an Oracle Wallet?

I have a unix server set up with an Oracle wallet that has the username/password of the user that will be connecting in the .net application. I modified the server sqlnet.ora file to have the wallet location and the entry SQLNET.WALLET_OVERRIDE = TRUE. I also modified the server side tnsnames.ora file with the new entry that was used when I added the user to the wallet using the "mkstore -wrl <wallet location> - createCredential <db_connect_string> <username> <password>.

My tnsnames.ora file looks something like this:

net_service_name =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = service_name)
)
)

So when I added my user to the wallet I did the following:
mkstore -wrl <wallet location> -createCredential net_service_name username password

When I test this out on my server with SQLPlus, I can connect /@net_service_name and it works fine.

It does not in the .net code. The coder used the following connection string:

connectionString="Data
Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hostname)(PORT=1521))(CONNECT/@net_service_name)))"


The .net application is not going to be running on my unix server, so what is needed to be able to connect via .net using the external password store that I have in the wallet? Do I need to create a tnsnames.ora file and sqlnet.ora file on the server hosting the .net application and also have the wallet on that same server?

and Connor said...

A typical odp.net connection looks like:

con.ConnectionString = "User Id=scott;Password=tiger;Data Source=a_tnsnames_entry";

so this would become

con.ConnectionString = "User Id=/;Data Source=a_tnsnames_entry";

because its the "a_tnsnames_entry" that allows the mapping into the wallet entry.



Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Christine Hayes, June 16, 2017 - 12:55 pm UTC


More to Explore

Security

All of the vital components for a secure database are covered in the Security guide.