0

请帮助我解决 Azure Sql Windows 模拟问题

有一个三层应用程序使用服务层上的模拟来以已启动客户端应用程序的用户身份连接到 MS SQL。

Kerberos 票证用于在服务上模拟客户端用户,如下所示:

SECURITY_HANDLE serverContext;

AcceptSecurityContext(ref inbound, ref serverContext, ref ClientToken, APIReference.ContextAttr, APIReference.SECURITY_NATIVE_DREP, out serverContext, out ServerToken, out uNewContextAttr, out NewLifeTime); // final handshake leg
ImpersonateSecurityContext(ref serverContext); //secur32.Dll

SqlConnection conn = new SqlConnection("Integrated Security=True") // works on MS SQL on premises

SqlConnection conn = new SqlConnection("Authentication=Active Directory Integrated"); // fails with Azure SQL (no impersonation is actually made)

RevertSecurityContext(ref _context); //secur32.Dll

但是,当 Kerberos 票证用于在 Azure SQL 上进行模拟(并且与本地 MSSQL 一起使用)时,不会进行用户模拟。问题是 SQL 查询是在服务用户帐户而不是客户端用户帐户下在 AzureSQL 上执行的。

是否可以让 Kerberos 票证模拟与 Azure SQL 一起使用?

我知道有 EXECUTE AS LOGIN 功能可用于在 Sql 服务器上模拟用户。但如果可能的话,我想让 Kerberos 模拟工作。

UPD:我在服务上使用了 adal.dll 来连接 AzureSQL

LogonUser我编写了使用令牌和WindowsIdentity.Impersonate()组合在 AzureSQL 上模拟的 c# 代码。但是,如果可能的话,我想使用 Kerberos 委托

更新

我没有找到使用 Kerberos 模拟用户并在服务被模拟为用户时连接到 Azure SQL 的方法。

但是我有用户 T-SQLexecute as user=revert命令来做数据库“模拟”

4

0 回答 0