ORA-01017: invalid username/password; logon denied when trying to connect via ODP.NET (Oracle.ManagedDataAccess.Client)

utopia picture utopia · Feb 18, 2020 · Viewed 7.4k times · Source

Following code throws: ORA-01017: invalid username/password; logon denied

string constr = "User Id=Name;Password=Password;Data Source=server:1521/service";
OracleConnection con = new OracleConnection(constr);
con.Open();

SQL Developer, DBeaver connects without problems. FIPS is disabled.

System:

  • Oracle Server 11g (11.2.0.3.0)
  • Oracle.ManagedDataAccess 19.6.0
  • .Net Framework 4.8
  • Windows 10 1909

I would be very thankful for any help!

Answer

Jon Heller picture Jon Heller · Feb 21, 2020

Assuming the password is correct (no offense, but 99.99% of the time, this error is because the password is wrong), one possible cause of this issue is case sensitivity and different password hash algorithms.

If you create a user with the password "PASSWORD", Oracle may create multiple different password hashes for it. One of the versions, meant to work with old clients, will work with either "PASSWORD" or "password". The newer version will only work with "PASSWORD". So you might be always using the wrong password, you're just getting lucky with the old client.

Oracle password hashes are a real mess. You can check things like the columns SYS.USER$.PASSWORD and SYS.USER$.SPARE4 for the hashes, or the SQLNET.ORA file for parameters meant to disable certain hashes. But most of the time you're better off just re-creating the password and seeing if that works.

(And if this is indeed the case, don't learn the wrong lesson and try to disable old password hash algorithms. It is much harder than the manual implies.)