从 SQL Express 实例创建到 SQL Azure 数据库的链接服务器时出错“此版本的 SQL 服务器不支持 Windows 登录。”

Error in creating a linked server to SQL Azure database from a SQL Express instance “Windows logins are not supported in this version of SQL Server.”

我正在尝试在虚拟机上使用 SQL Express 2019 将链接服务器设置到 Azure 数据仓库。我已经使用 sql 登录成功创建了链接服务器,但是 AAD 登录不起作用。

我正在使用以下字符串

Server=tcp:sqldw.windows.net,1433;Initial Catalog=sqldb;Persist Security Info=False;;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Authentication="Active Directory Integrated";

这是错误:
Windows 此版本的 SQL 服务器不支持登录。 (.Net SqlClient 数据提供者)

如果您是 EF Core 使用 v3.0 而不是 System.Data.SqlClient, starting with V3.0. Please have the latest Microsoft.Data.SqlClient 版本,目前(包括预览版)仅支持这两个 NET Framework 选择。"

注意:NetCore 程序目前不支持 ActiveDirectoryIntegratedActiveDirectoryInteractive 身份验证选项。

Active Directory Integrated 在 .NET Core 3.1 中无法使用,但现在只要安装了 NuGet 包 Microsoft.Data.SqlClient// v2.0.1 版本就可以使用。它现在适用于以下连接字符串:

"ipsdbconnstr": "Server=tcp:ipsdbserver.database.windows.net,1433;Database=MyDb;Authentication=ActiveDirectoryIntegrated"

使用附加属性,示例如下:

;用户 ID=userid@mydomain.com;持久安全信息=true;加密=true;TrustServerCertificate=true;MultipleActiveResultSets=true

TrustServerCertificate 设置为 false 时,SQL 服务器 SSL 证书上的服务器名称(或 IP 地址)必须与连接字符串中给出的服务器(或 IP 地址)名称完全匹配并且 Encrypt 设置为 true。

否则,连接的努力被侵犯。换句话说,执行的唯一安全检查是“encrypt=truetrustservercertificate=false”的组合,用于验证主机名证书是否与您要连接的服务器主机名匹配。

trustservercertificate=false不接受自动签名证书,因此仍然需要使用 known/trustworthy CA 签署证书。

设置 TrustServerCertificate=true 以解决问题。

您应该使用来自联合域的 Azure Active Directory 凭据登录 Windows,或配置为无缝单点登录以进行直通和密码哈希身份验证的托管域。

供您参考的文件

Azure Active Directory Seamless Single Sign-On.

Azure AD Connect: Seamless Single Sign-On - How it works | Microsoft Docs