Can't connect to Oracle using Windows Authentication with ODP.NET

邮差的信 提交于 2019-12-11 05:51:00

问题


I've configured my Oracle Database for NTS Authentication and set my Windows Login up as a user in the database.

I'm able to log in to the Database with the command sqlplus /.

I'm also able to connect using Windows Authentication using the System.Data.OracleClient provider for ADO.NET.

For example, the following code snippet works:

DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OracleClient");
DbConnection connection = factory.CreateConnection();
connection.ConnectionString = "Data Source=//localhost/Test; Integrated Security=yes";
connection.Open();

However, I'm unable to connect using Windows Authentication using Oracle.DataAccess.Client (ODP.NET).

DbProviderFactory factory = DbProviderFactories.GetFactory("Oracle.DataAccess.Client");
DbConnection connection = factory.CreateConnection();
connection.ConnectionString = "Data Source=//localhost/Test; User Id=/";
connection.Open();

This block of code results in the following exception:

Oracle.DataAccess.Client.OracleException was unhandled Message=ORA-1017: invalid username/password; logon denied

According to this link I should be able to create an ODP.NET connection to Oracle using the provided connection string: http://www.oracle.com/technetwork/articles/dotnet/cook-masteringdotnet-090821.html

Why does the ODP.NET client not allow me to connect while the (deprecated) Microsoft client does?

This problem was discussed at the following thread in 2007, but no solution was every provided: http://forums.oracle.com/forums/thread.jspa?messageID=2312148.

This is a showstopper.


回答1:


It works fine for me using ODP.net 11 and this connection string (with a tnsnames.ora file in the Oracle client to define DLGP): Data Source=DLGP;User Id=/;Password=;

Your sqnet.ora file needs to be setup correctly for this to work, but that should already be the case if SQLPlus can connect. Do you only have one Oracle home? If ODP.net is picking up a second one that can muck things up nicely (and that can happen depending on how you install it).



来源:https://stackoverflow.com/questions/6957076/cant-connect-to-oracle-using-windows-authentication-with-odp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!