mkleehammer / pyodbc

Python ODBC bridge
https://github.com/mkleehammer/pyodbc/wiki
MIT No Attribution
2.88k stars 562 forks source link

Unable to connect to SQL managed instance from Linux, works with Windows #1174

Closed luisaranda closed 1 year ago

luisaranda commented 1 year ago

Please first make sure you have looked at:

Environment

To diagnose, we usually need to know the following, including version numbers. On Windows, be sure to specify 32-bit Python or 64-bit:

Issue

The Authentication is set to ActiveDirectoryIntegrated and trying to connect to an Azure SQL Managed Instance. Our Azure Active Directory credentials are federated with OKTA. Authentication fundamentals: Federation | Azure Active Directory

The problem is if the application runs on Linux (Ubuntu) the connection fails. When using Windows, the connection works. The application is on premises.

We collected an ODBC trace log when the connection fails. odbctrace.log

Is this expected? Is ActiveDirectoryIntegrated supported with Linux?

Searched on the wiki but couldn't find anything conclusive.

Would appreciate your expertise. Thanks in advance!

v-chojas commented 1 year ago

This has nothing to do with pyODBC. ActiveDirectoryIntegrated will need a valid Kerberos set up. See documentation for more information: https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/using-integrated-authentication?view=sql-server-ver16

artgoldberg commented 1 year ago

@luisaranda Since a Linux user doesn't local Windows AAD credentials, they need to be made available. Use the Kerberos kinit command to initialize a Kerberos token that the odbc driver can use to authenticate the user to SQL Server.

mkleehammer commented 1 year ago

Thanks artgoldberg. I'm going to close this since it is unrelated to pyodbc.