I am connecting to an Azure SQL database using pyodcb
. We have multi-factor authentication enabled, so I am using ActiveDirectoryInteractive
authentication. We also use single sign-on for Windows.
My code is as follows:
import pyodbc
driver = '{ODBC Driver 17 for SQL Server}'
server = 'xxxxxxxxxxxxx.database.windows.net'
database = 'xxxxxxxxxxxxx'
authentication = 'ActiveDirectoryInteractive'
username = 'xxxxxxxxxxxxx'
conn = pyodbc.connect(
'DRIVER=' + driver + ';' +
'SERVER=' + server + ';' +
'DATABASE=' + database + ';' +
'UID=' + username + ';' +
'AUTHENTICATION=' + authentication + ';')
cursor = conn.cursor()
Running this script, I get the password prompt, followed by the prompt to enter my MFA code, and this connects successfully.
But I would have thought that these steps were unnecessary, given we're using single sign-on. In fact, if I close the password prompt without entering my password the connection is still made. So if single sign-on is working correctly and the password and MFA prompts are not necessary, how can I suppress them?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.