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

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

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.

.NET 9 - Goodbye sln!

Although the csproj file evolved and simplified a lot over time, the Visual Studio solution file (.sln) remained an ugly file format full of magic GUIDs. With the latest .NET 9 SDK(9.0.200), we finally got an alternative; a new XML-based solution file(.slnx) got introduced in preview. So say goodbye to this ugly sln file: And meet his better looking slnx brother instead: To use this feature we first have to enable it: Go to Tools -> Options -> Environment -> Preview Features Check the checkbox next to Use Solution File Persistence Model Now we can migrate an existing sln file to slnx using the following command: dotnet sln migrate AICalculator.sln .slnx file D:\Projects\Test\AICalculator\AICalculator.slnx generated. Or create a new Visual Studio solution using the slnx format: dotnet new sln --format slnx The template "Solution File" was created successfully. The new format is not yet recognized by VSCode but it does work in Jetbr...