You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将SqlPackage.exe的SQL登录替换为域用户认证?

修改sqlpackage.exe命令以使用域用户认证

Got it, let's walk through how to adjust your sqlpackage command to use domain user authentication instead of SQL login.

核心思路

Your original /TargetUser and /TargetPassword parameters are designed for SQL Server authentication. For domain (Windows) authentication, the most reliable approach is to use the /TargetConnectionString parameter, which lets you pass a full SQL Server connection string that includes the integrated security settings and your domain credentials.

修改后的命令

Replace the SQL login parameters with a connection string that matches your requirement:

sqlpackage.exe /SourceFile:"<location of dacpac>" /Action:Publish /TargetConnectionString:"Server=server;Database=database;Integrated Security=SSPI;User ID=domain\user;Password=pass1;"

关键细节解释

  • Integrated Security=SSPI: This tells SQL Server to use Windows authentication (which supports domain users).
  • User ID=domain\user: Specifies your full domain-qualified username (format: domain\username).
  • Password=pass1: Adds the password for the domain user (this is needed if you're not running the script under the domain user's context already).

备选方案(使用单独参数)

If you prefer to keep individual parameters instead of a full connection string, you can use these settings (note: this works in newer versions of sqlpackage):

sqlpackage.exe /SourceFile:"<location of dacpac>" /Action:Publish /TargetServerName:"server" /TargetDatabaseName:"database" /TargetIntegratedSecurity:True /TargetUser:"domain\user" /TargetPassword:"pass1"

However, the connection string approach is more universally compatible and aligns directly with the SQL connection string format you referenced.

内容的提问来源于stack exchange,提问作者Astrid

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:43:51