title: How do I deploy using MSDeploy and TeamCity with Integrated Windows Authentication?
body: <p>I had a MSDeploy deployment working beautifully with TeamCity when I passed in the user credentials.  The command line parameters (using env. variables for some values) were:</p>
  
  <blockquote>
    <p>MSBuild.exe Web.csproj
    <br>/P:Configuration=%env.Configuration% 
    <br>/P:DeployOnBuild=True 
    <br>/P:DeployTarget=MSDeployPublish 
    <br>/P:MsDeployServiceUrl=<a href="https://%env.TargetServer%/MsDeploy.axd" rel="nofollow noreferrer">https://%env.TargetServer%/MsDeploy.axd</a> <br>/P:AllowUntrustedCertificate=True 
    <br>/P:MSDeployPublishMethod=WMsvc 
    <br>/P:CreatePackageOnPublish=True 
    <br>/P:UserName=%env.AdminUser% 
    <br>/P:Password=%env.AdminPassword%</p>
  </blockquote>
  
  <p>Worked great.  But now I want to use integrated auth. I tried following Troy's suggestions over from <a href="https://stackoverflow.com/questions/4210379/can-msbuild-deploy-using-integrated-authentication-or-only-basic">Can MSBuild deploy using integrated authentication or only basic?</a> but it's not doing the trick.  I've tried various combinations of passing in a blank username and specifying </p>
  
  <blockquote>
    <p>/p:AuthType=NTLM</p>
  </blockquote>
  
  <p>The closest I get is by specifying /p:AuthType=NTLM and passing in a blank username.  But that still results in this error:</p>
  
  <blockquote>
    <p>Connected to the destination computer ("[my destination server name]") using the Web Management Service, but could not authorize. Make sure that you are using the correct user name and password, that the site you are connecting to exists, and that the credentials represent a user who has permissions to access the site. The remote server returned an error: (401) Unauthorized</p>
  </blockquote>
  
  <p>I have the Web Management Service running on both the local and remote servers.  I changed both instances to run as a user I know has proper access to the site - the same user that works if I manually pass in credentials.  </p>
  
  <p>I also tried manually giving that user IIS Manager Permissions on the destination site (though not sure why that would be necessary since the user can publish to the site when their credentials are manually passed).  </p>
  
  <p>One thing I am noticing is that in the WMsvc log it's not logging any username for the attempts made with NTLM auth.  </p>
  
  <p>Any idea what's going on here.  I really don't want to have to store user credentials in my TeamCity configuration.</p>
  
  <p>Thanks.</p>