Sometimes you can face something like an error related to Access Denied when activating feature in SharePoint. It’s pretty common to happen when we are developing an automatized routine or anything that access SharePoint administration objects. As an example it can be Timer Job that will run in a specific schedule and you creates it on feature activation.

Access Denied page - Access Denied when activating feature in SharePoint
Access Denied page

Feature Receiver used when activating in SharePoint

If you know that’s the case of a Timer Job or something related to SharePoint Farm Administration, then you probably know that it is inside your custom Feature Receiver. Probably it’s installing artifacts through code to the SharePoint Farm during the deployment process. This error may not occur when developing or deploying through PowerShell if you set the feature to be activated automatically.

But let’s say if your SharePoint administrator forgot to enable it and you had to do it manually. Or if you are in an development environment and you want to debug the Feature receiver to find a bug.

Basically you will browse the Manage Features page, find the feature and then suddenly an exception happens presenting a message of Access Denied!

Access Denied solution when activating

Well, that happened because you are probably accessing from a remote machine. Usually, SharePoint doesn’t allow changes made to Administration objects coming from outside the server like your personal computer, for example. But if you do the same inside the Servers in the farm, using the interface or PowerShell, then it will work.

To overcome that issue, you can just run this code below and you will be able to enable the feature without problems:

Final observations on this SharePoint configuration

1) It’s not recommended to run this snippet in production environment, due security issues;
2) The account enabling the feature must have access like the System Account;
3) The “Access Denied” message won’t show up if you enable the feature by PowerShell.

Anyway, hope this post help you when troubleshotting Access denied when activating feature in SharePoint. You may also be interested on checking a post on optimizing your SharePoint environment if you face a problem related to this post.

References:
Paul Kotlyar’s .NET Adventures
Microsoft