Tooling: Web Deploy and ERROR_USER_NOT_AN_ADMIN

Created on 24 May 2016  路  17Comments  路  Source: aspnet/Tooling

I'm trying to publish an RC2 to IIS both on my local machine (ie. localhost for testing) and my live server.

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(406,5): Error : Error Code: ERROR_USER_NOT_ADMIN
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(406,5): Error : More Information: Connected to 'west-wind.com' using the Web Deployment Agent Service, but could not authorize. Make sure you are an administrator on 'site.com'.  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_NOT_ADMIN.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(406,5): Error : Error: The remote server returned an error: (401) Unauthorized.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(406,5): Error : Error count: 1.

However, I am an admin on the server, and I explicitly added the MsDepSvc account yet it still fails.

It looks like IIS hookup and starting now works more easily, so it looks promising that publishing should work using the existing publishing pipeline if I could get past this particular error.

Could it be a version conflict? I suspect I'm running Web Deploy 3.5 on the server, and the new project tools are perhaps 3.6? Publish seems to work fine in other project types on this machine to the same server.

TFS Tracked

Most helpful comment

@RickStrahl - Can you try taking the the latest version of the script from here - https://github.com/aspnet/vsweb-publish/blob/master/publish-module.psm1

and adding the following property to your pubxml:
<AuthType>NTLM</AuthType>

All 17 comments

@vijayrkn is this the same issue you were looking at with Frank on email?

Looks like the same issue.

Can you copy the contents of this file
https://raw.githubusercontent.com/aspnet/vsweb-publish/master/publish-module.psm1
to
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\Publish\Scripts\1.1.0\publish-module.psm1

to see if it fixes the issue? We will be releasing a newer version of the script with the fix soon.

Ok, I copied in the new script restarted VS and published again. Same issue and same admin error.

FWIW, the Validate Connection button shows valid, and I can publish individual files like say index.html. They are pushed to the server, so it looks like there's no actual problem with Web Deploy or permissions. It appears to be specific to publishing the RC2 bits. Error is the same with the new script as above.

Thanks for checking...

The newer version of the script wont work for rc1 projects. It will work only for rc2 projects.
For rc1 projects, we need to use a different webdeploy provider. The last script version supported for rc1 projects is 1.0.1.

Sorry my bad - I meant RC2... I'm running RC2.

Is it possible to share the msdeploy command used for publishing (it shows up in the output window while publishing from VS)?

Executing command ["C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" -source:manifest='C:\temp\tmpfiles\PublishTemp\obj\SourceManifest.xml' -dest:manifest='C:\temp\tmpfiles\PublishTemp\obj\DestManifest.xml',ComputerName='http://west-wind.com/MSDEPLOYAGENTSERVICE',UserName='user',Password='{PASSWORD-REMOVED-FROM-LOG}',IncludeAcls='False',AuthType='Basic' -verb:sync -enablerule:AppOffline -enableRule:DoNotDeleteRule -retryAttempts:20 -disablerule:BackupRule]

This looks like a different issue. The one we fixed was for 'WMSVC'. Will investigate.

If you need more info let me know...

@RickStrahl I think we have some issue with the command being issued to msdeploy.exe. Can you try this:

  1. Create a ASP.NET 4 project
  2. Create a publish profile to the web app
  3. Edit the publish profile (.pubxml) to have <UseMSDeployExe>true</UseMSDeployExe>
  4. Publish

Then can you paste in the call that works (removing username/password values) here?

@RickStrahl - Can you try taking the the latest version of the script from here - https://github.com/aspnet/vsweb-publish/blob/master/publish-module.psm1

and adding the following property to your pubxml:
<AuthType>NTLM</AuthType>

TFS: 226143
I've added this to our internal TFS, we will reply back here soon.

@vijayrkn Yup that did the trick. New script and AuthType and now the publish works.

Should we expect the AuthType flag to be there in the future by default for MsDeploy based publish?

The reason "AuthType" had to be set in this case is because you were using the remote agent service. By default publish uses wmsvc and AuthType as basic. The remote service does not support basic authentication. Will work with @sayedihashimi to see what the default experience needs to be for the remote service. Thanks for confirming.

I had a similar problem and:

taking the the latest version of the script from here - https://github.com/aspnet/vsweb-publish/blob/master/publish-module.psm1

and adding the following property to your pubxml:
NTLM

worked.

I made progress by upgrading the webdeploy version on the server from 3.5 to 3.6 and adding the AuthType to be NTLM. I can now publish successfully, however publish preview still fails with an authorization error

Was this page helpful?
0 / 5 - 0 ratings