【问题标题】:Azure SQL Database connection using Active Directory Integrated authentication fails to open使用 Active Directory 集成身份验证的 Azure SQL 数据库连接无法打开
【发布时间】:2018-01-17 18:14:21
【问题描述】:

我正在尝试使用类似于以下的连接字符串通过实体框架连接到 Azure SQL 数据库:

Data Source=<server>.database.windows.net;Authentication=Active Directory Integrated;Initial Catalog=<database>

连接尝试是在 AutoCAD 2018 中运行的托管 WPF 表单的上下文中进行的。该项目是使用 .NET Framework 4.6 和 EF 6.1.3 构建的。

我遇到以下错误:

Unable to load adalsql.dll (Authentication=ActiveDirectoryIntegrated). Error code: 0x2. For more information, see http://go.microsoft.com/fwlink/?LinkID=513072

很遗憾,帮助链接没有指向提供有关此问题的技术详细信息的页面。到目前为止,我还没有在网上发现任何说明根本原因的东西。

我也试过这个连接字符串:

Server=tcp:<server>.database.windows.net,1433;Initial Catalog=<database>;Persist Security Info=False;User ID=<username>;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Authentication="Active Directory Integrated"

它是从 Azure 门户的 ADO.NET (Active Directory integrated authentication) 部分复制的。但是,使用此连接字符串时,我收到以下错误 Cannot use 'Authentication=Active Directory Integrated' with 'User ID', 'UID', 'Password' or 'PWD' connection string keywords

但它不包含密码段。删除User ID 段后,我仍然收到Unable to load adalsql.dll ... 错误。

【问题讨论】:

  • 你能解决这个错误吗?请告诉我们。由于我们面临同样的问题,这会有所帮助。
  • 不,我从来没有解决过。我最终使用 SQL Server 密码身份验证而不是 AD 身份验证。
  • 我正在使用 Powershell 连接到 Azure SQL 并面临同样的问题。如果我删除密码和 UID,我会收到“WSTrust 响应没有识别 SAML 断言”

标签: entity-framework ado.net autocad-plugin


【解决方案1】:

连接字符串 Server=<server>.database.windows.net,1433; Authentication=Active Directory Integrated; Initial Catalog=<database>; 如果您遵循此 hack,则可以使用:

    /// <summary>
    /// HACK: Refer to https://stackoverflow.com/a/19130718/852956
    /// </summary>
    public void FixEfProviderServicesProblem() {
        //The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer'
        //for the 'System.Data.SqlClient' ADO.NET provider could not be loaded. 
        //Make sure the provider assembly is available to the running application. 
        //See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

        SqlProviderServices instance = SqlProviderServices.Instance;
    }

【讨论】:

    猜你喜欢
    • 2018-09-21
    • 1970-01-01
    • 1970-01-01
    • 2019-11-16
    • 1970-01-01
    • 2020-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多