[英]ODBC connection to Azure using ActiveDirectoryInteractive
I am connecting to an Azure SQL database using pyodcb
.我正在使用
pyodcb
连接到 Azure SQL 数据库。 We have multi-factor authentication enabled, so I am using ActiveDirectoryInteractive
authentication.我们启用了多因素身份验证,因此我使用
ActiveDirectoryInteractive
身份验证。 We also use single sign-on for Windows.我们还对 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.运行此脚本,我收到密码提示,然后提示输入我的 MFA 代码,并且连接成功。
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?
因此,如果单点登录正常工作并且不需要密码和 MFA 提示,我该如何禁止它们?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.