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

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.

Kubernetes–Limit your environmental impact

Reducing the carbon footprint and CO2 emission of our (cloud) workloads, is a responsibility of all of us. If you are running a Kubernetes cluster, have a look at Kube-Green . kube-green is a simple Kubernetes operator that automatically shuts down (some of) your pods when you don't need them. A single pod produces about 11 Kg CO2eq per year( here the calculation). Reason enough to give it a try! Installing kube-green in your cluster The easiest way to install the operator in your cluster is through kubectl. We first need to install a cert-manager: kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.14.5/cert-manager.yaml Remark: Wait a minute before you continue as it can take some time before the cert-manager is up & running inside your cluster. Now we can install the kube-green operator: kubectl apply -f https://github.com/kube-green/kube-green/releases/latest/download/kube-green.yaml Now in the namespace where we want t...

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 Col...