4

For some security reasons on one of our farm level solutions, we need to limit some actions using Event Receiver-FileMoving event. However, as known, event receivers can be deployed only by Site or SiteCollection level features. Since the solution that provides the main functionality is on farm scope, we need to be able to apply this event receiver to each and every document library there is.

I thought of creating a site level feature for the event receiver, and then enable it on all sites via FeatureActivated event of the farm scoped feature. But it doesn't cover new sites being added after the feature is activated. And since there is no setting for Site level features to "default enable", it doesn't work.

Then I found out Site Added event, where I can enable the feature as soon as it's added. But, from what I understand, it's also site(SPWeb) scoped, so new web applications and site collections are not covered.

So, any ideas how I can make a farm scoped solution to deploy FileMoving event throughout the farm?

Sharepoint 2010/2013 Enterprise edition

3

You can use feature stapling to achieve this. You just deploy a simple element file in a feature and activate it at the web application level.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <FeatureSiteTemplateAssociation Id="the guid of the feature to staple to new sites" TemplateName="GLOBAL"/>
</Elements>

Also see this rather informative SP.SE post about feature stapling:

What is "feature stapling"?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.