views:

30

answers:

1

I am trying to activate a SharePoint feature through code. SPWeb.Features.Add(new GUID("XXXXXX")

This above line is written in featureinstalled event handler where I am reading all the sites on the farm and activating the feature on each site.

But upon activation it is not calling / trigger the featureactivated event handler where I have some code to run. Can someone suggest how to trigger that event.

A: 

Are you looking for Feature Stapling? http://blogs.msdn.com/b/cjohnson/archive/2006/11/01/feature-stapling-in-wss-v3.aspx Or is there a requirement that rules this out? Can your users create sites?

Also at what scope are you deploying the feature? If you scope it at farm or web application it will be activated/deactivated in all your sites.

Junx
It is a web part deployed as a feature. The user dose not have permission to create sites/subsites. Because of this locked down security model, the user is not able to activate a feauture (I am also looking at how to give only this permission to the end user). As this is a webpart it is depolyed at web scope and I cannot deploy at farm scope (As microsoft says). This webpart will be available for all site on the farm. For future sites we create, it will be actiavted by default during provisioning process.
sssreddy
You need to change the scope of your feature to Site Collection (Scope=Site). When you use STSADM -o deploysolution you need to specify the top level Site Collection or -allcontenturls. After you deploy it you simply go to the Site Collection features page in the root of your site and activate the feature. It should show up everywhere.
Junx