相关疑难解决方法(0)

使用 MFA Active Directory 交互式身份验证在 Python 中连接到 Azure SQL,而不使用 Microsoft.IdentityModel.Clients.ActiveDirectory dll

要使用 MFA(在 SSMS 中作为“Active Directory - Universal”)连接到 Azure SQL 数据库,Microsoft 建议并且目前只有使用 Microsoft.IdentityModel.Clients.ActiveDirectory 与 C# 连接的教程

Authentication='Active Directory Interactive';从 Python 或 Powershell设置常规 ODBC 连接字符串会导致错误

Cannot find an authentication provider for 'ActiveDirectoryInteractive'
Run Code Online (Sandbox Code Playgroud)

这似乎是因为根据https://docs.microsoft.com/en-us/azure/sql-database/active-directory-interactive-connect-azure-sql-db 上的Microsoft 示例代码,您需要明确创建自己的创建连接时的身份验证提供程序类:


        public static void Main(string[] args)
        {
            var provider = new ActiveDirectoryAuthProvider();

            SC.SqlAuthenticationProvider.SetProvider(
                SC.SqlAuthenticationMethod.ActiveDirectoryInteractive,
                //SC.SqlAuthenticationMethod.ActiveDirectoryIntegrated,  // Alternatives.
                //SC.SqlAuthenticationMethod.ActiveDirectoryPassword,
                provider);

            Program.Connection();
        }
Run Code Online (Sandbox Code Playgroud)

我想与pyodbc 连接,所以我无法实现ActiveDirectoryInteractive 提供程序。

有什么方法可以使用 OAuth 获取令牌并在连接字符串中使用它,或者在不使用 .NET 的情况下以其他方式实现 ActiveDirectoryInteractive 提供程序?

odbc azure pyodbc azure-sql-database multi-factor-authentication

6
推荐指数
2
解决办法
4906
查看次数