ORA-01005 error connecting with ODP.Net

邮差的信 提交于 2019-12-11 03:55:46

问题


I am trying to access an Oracle database (version 10.2.0.4.0) using the following code but an "ORA-01005: Null password given; logon denied" exception is raised by the connection when it's open method is called.

        var connBuilder = new OracleConnectionStringBuilder();
        connBuilder.DataSource = "(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = MyHost.Address)(PORT = ####)) )(CONNECT_DATA =(SERVICE_NAME = MyService)))";
        connBuilder.UserID = "validUserId";
        connBuilder.Password = "validPassword";
        connBuilder.PersistSecurityInfo = true;
        var connString = connBuilder.ToString();
        using (var con = new OracleConnection(connString))
        {
            con.Open();
        }

If I change the username then I receive the following instead; "ORA-01017: invalid username/password; logon denied" and this is also the case if I change the open call on the connection with con.OpenWithNewPassword("validPassword");

If I try with the deprecated Oracle client it connects with no problems:

        using (var depCon = new System.Data.OracleClient.OracleConnection
           ("Data Source=MyHost.Address:####/MyService;Persist Security Info=True;
             User ID=validUsername;Password=validPassword;Unicode=True"))
        {
            depCon.Open();
        } 

I'd (obviously) like to use the latest Odp.Net drivers but can't seem to get past this issue. Has anybody got any ideas?


回答1:


Take a look at this thread for an issue regarding FIPS compliance:

https://community.oracle.com/thread/2557592?start=0&tstart=0

Also: Oracle.ManagedDataAccess and ORA-01017: invalid username/password; logon denied




回答2:


Does it work when you do it like this:

var connBuilder = new Common.DbConnectionStringBuilder();
connBuilder.Add("Data Source", "(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = MyHost.Address)(PORT = ####)) )(CONNECT_DATA =(SERVICE_NAME = MyService)))";
connBuilder.Add("User Id", "validUserId");
connBuilder.Add("Password", "validPassword");

Which version of ODP.NET do you use? There are known issues when you connect to a "new" Oracle database with case-sensitive passwords using an "old" ODP.NET provider, see here: https://community.oracle.com/message/2198228

In order to verify run this command on your database:

ALTER SYSTEM SET SEC_CASE_SENSITIVE_LOGON = FALSE;



回答3:


The issue with case sensitivity and the ODP.Net drivers and different DB versions should be a simple fix. Enclose your connectionstring password in quotes(") such as Password=\"password\"; and this should keep the password case



来源:https://stackoverflow.com/questions/31785650/ora-01005-error-connecting-with-odp-net

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