Skip to main content

WebDeploy error: System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.

When trying to deploy a web application from Visual Studio, it failed with the following error message:

clip_image002

This error message didn’t help much so I logged on to the server where I found the following error info in the Event log:

User:

Client IP: 10.1.210.31

Content-Type: application/msdeploy

Version: 9.0.0.0

MSDeploy.VersionMin: 7.1.600.0

MSDeploy.VersionMax: 9.0.1631.0

MSDeploy.Method: Sync

MSDeploy.RequestId: 3e4d3744-90cf-4c95-85c9-28eb30970c3e

MSDeploy.RequestCulture: nl-BE

MSDeploy.RequestUICulture: en-US

ServerVersion: 9.0.1631.0

Skip: objectName="^configProtectedData$"

Provider: auto, Path:

A tracing deployment agent exception occurred that was propagated to the client. Request ID '3e4d3744-90cf-4c95-85c9-28eb30970c3e'. Request Timestamp: '8/01/2013 11:41:32'. Error Details:

System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.

   at System.Security.AccessControl.Win32.SetSecurityInfo(ResourceType type, String name, SafeHandle handle, SecurityInfos securityInformation, SecurityIdentifier owner, SecurityIdentifier group, GenericAcl sacl, GenericAcl dacl)

   at System.Security.AccessControl.NativeObjectSecurity.Persist(String name, SafeHandle handle, AccessControlSections includeSections, Object exceptionContext)

   at System.Security.AccessControl.NativeObjectSecurity.Persist(String name, AccessControlSections includeSections, Object exceptionContext)

   at Microsoft.Web.Deployment.FileSystemSecurityEx.Persist(String path, Boolean isFile)

   at Microsoft.Web.Deployment.SetAclProvider.Add(DeploymentObject source, Boolean whatIf)

   at Microsoft.Web.Deployment.DeploymentObject.Update(DeploymentObject source, DeploymentSyncContext syncContext)

   at Microsoft.Web.Deployment.DeploymentSyncContext.HandleUpdate(DeploymentObject destObject, DeploymentObject sourceObject)

   at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildrenOrder(DeploymentObject dest, DeploymentObject source)

   at Microsoft.Web.Deployment.DeploymentSyncContext.ProcessSync(DeploymentObject destinationObject, DeploymentObject sourceObject)

   at Microsoft.Web.Deployment.DeploymentObject.SyncToInternal(DeploymentObject destObject, DeploymentSyncOptions syncOptions, PayloadTable payloadTable, ContentRootTable contentRootTable, Nullable`1 syncPassId)

   at Microsoft.Web.Deployment.DeploymentAgent.HandleSync(DeploymentAgentAsyncData asyncData, Nullable`1 passId)

   at Microsoft.Web.Deployment.DeploymentAgent.HandleRequestWorker(DeploymentAgentAsyncData asyncData)

   at Microsoft.Web.Deployment.DeploymentAgent.HandleRequest(DeploymentAgentAsyncData asyncData)

Based on the UnauthorizedAccessException, I’m guessing that I forgot to configure some security settings in IIS. So let’s try to fix this…

  • Open the IIS Manager. Select the web site you want to deploy to on the left. On the Features view on the right look for the Management block:

clip_image002[6]

  • Select IIS Manager Permissions and click on the Allow User… action in the Actions menu on the right.

clip_image004

  • The Allow User… dialog is loaded. If you have configured a specific account to manage web deploy select the IIS Manager radio button(otherwise choose the Windows radio button). Click on the Select… button to select a user.

clip_image006

  • Choose a user from the list and click OK.

clip_image008

  • Click OK again.

clip_image010

After doing this, the IIS Manager account (in this case WebDeployUser) can be used when you want to deploy through web deploy.

As a last step, we’ll have to give IIS the necessary rights to create folders and add files to the target location. So browse to the target folder and give the Local Service user ‘Full Control’ access rights.

That’s it…

Popular posts from this blog

DevToys–A swiss army knife for developers

As a developer there are a lot of small tasks you need to do as part of your coding, debugging and testing activities.  DevToys is an offline windows app that tries to help you with these tasks. Instead of using different websites you get a fully offline experience offering help for a large list of tasks. Many tools are available. Here is the current list: Converters JSON <> YAML Timestamp Number Base Cron Parser Encoders / Decoders HTML URL Base64 Text & Image GZip JWT Decoder Formatters JSON SQL XML Generators Hash (MD5, SHA1, SHA256, SHA512) UUID 1 and 4 Lorem Ipsum Checksum Text Escape / Unescape Inspector & Case Converter Regex Tester Text Comparer XML Validator Markdown Preview Graphic Color B

Help! I accidently enabled HSTS–on localhost

I ran into an issue after accidently enabling HSTS for a website on localhost. This was not an issue for the original website that was running in IIS and had a certificate configured. But when I tried to run an Angular app a little bit later on http://localhost:4200 the browser redirected me immediately to https://localhost . Whoops! That was not what I wanted in this case. To fix it, you need to go the network settings of your browser, there are available at: chrome://net-internals/#hsts edge://net-internals/#hsts brave://net-internals/#hsts Enter ‘localhost’ in the domain textbox under the Delete domain security policies section and hit Delete . That should do the trick…

Azure DevOps/ GitHub emoji

I’m really bad at remembering emoji’s. So here is cheat sheet with all emoji’s that can be used in tools that support the github emoji markdown markup: All credits go to rcaviers who created this list.