title: Executing Sql with Integrated Security via TeamCity fails at user login
body: <p>I have an MSBuild script which uses the MSBuildExtensions <code>SqlExecute</code> command similar to the following:</p>
  
  <pre><code>&lt;Target Name="DoSqlStuff"&gt;
      &lt;SqlExecute TaskAction="Execute"
                  UseTransaction="True"
                  ConnectionString="Data Source=$(Sql_ServerName); Initial Catalog=$(Sql_DatabaseName); Integrated Security=SSPI;"
                  Files="@(sqlFiles)"
                  CommandTimeout="1800"&gt;
      &lt;/SqlExecute&gt;
  &lt;/Target&gt;
  </code></pre>
  
  <p>If I run this from the command line (with all the correct variables and whatnot) then it works just fine.</p>
  
  <p>I have a TeamCity build agent set up to be the same machine that can successfully run this MSBuild script (with all the same variables entered) from the command line, and I get the following error:</p>
  
  <pre><code>[MSBuild output] C:\BuildAgent\work\c5affefc453a825c\ContinuousBuild\Deploy.proj(22,3): error : SqlException: Login failed for user 'ALLIANCE\DANIELM$'. [C:\BuildAgent\work\c5affefc453a825c\ContinuousBuild\Deploy.proj.teamcity]
  </code></pre>
  
  <p>I added some debug output to this task:</p>
  
  <pre><code>&lt;Message Text="Current user is $(USERNAME)" /&gt;
  &lt;Message Text="Current domain is $(USERDOMAIN)" /&gt;
  </code></pre>
  
  <p>When run via cmd, the user name is <code>danielm</code></p>
  
  <p>When run via TeamCity, the user name is <code>danielm$</code></p>
  
  <p>The domain is the same for both.</p>
  
  <p>What am I doing wrong, or what next steps do I need to perform to get more info?</p>