Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect with System.Data.OracleClient to oracle db with windows authentication?

With Oracle SQL Developer I can put / -character to Username and leave password empty and I get connected. I have OP$MYWINDOWSUSERNAME user created in database.

EDIT: SQL Developer does not work if I check OS Authentication-checkbox (empties and disables username + pwd). Moreover Preferences->Database->Advanced->Use Oracle Client is unchecked so I guess what SQL Developer does or doesn't has very little to do with my System.Data.OracleClient.OracleConnection problem.

However when I try to form connection string like this:

string.Format("Data Source={0}; user id=/;password=;Integrated Security=yes", dbName);

I get ORA-01017: invalid username/password: logon denied

with

string.Format("Data Source={0}; user id=/;password=;Integrated Security=no", dbName);

I get ORA-01005.

With

string.Format("Data Source={0};Integrated Security=yes", dbName);

I get ORA-01017: invalid username/password: logon denied

With

string.Format("Data Source={0}; user id=/;", dbName);

I get ORA-01005

With

string.Format("Data Source={0};User Id=/;Integrated Security=yes;", dbName);

I get ORA-01017

Both OracleConnection in my program and Oracle SQL Developer work when I specify Username and password.

EDIT: This works with

string.Format("Data Source={0};Integrated Security=yes", dbName);

when sqlnet.ora line

SQLNET.AUTHENTICATION_SERVICES= (NTS) 

is changed to

SQLNET.AUTHENTICATION_SERVICES= (NONE)

If somebody writes short answer what is happening and why, i'm happy to grant bounty to him/her.

like image 608
char m Avatar asked Mar 16 '17 13:03

char m


People also ask

Can Oracle use Windows authentication?

The Windows native authentication adapter (automatically installed with Oracle Net Services) enables database user authentication through Windows. This enables client computers to make secure connections to Oracle Database on a Windows server. The server then permits the user to perform database actions on the server.


1 Answers

In short, it's the Windows native operating system authentication which is indicated by NTS.

Once NTS is specified, oracle client identifies the username as workgroup\username or domain\username which does not match your OP$MYWINDOWSUSERNAME database user

In order to have it working with NTS option, you need to include domain/workgroup name in your db username:

CREATE USER "OPS$<DOMAIN_NAME>\<OS_USERNAME>" IDENTIFIED EXTERNALLY;

oracle support document 750436.1 confirms this with detailed steps.

like image 137
lsalamon Avatar answered Sep 23 '22 06:09

lsalamon