I am working on a web application-scoped feature which creates a site collection. I would like to set the person who activated the feature as site collection owner. To do that, I would have to either:

  • find out who started the featurereceiver
  • find out who the current user is inside the featurereceiver

For obvious reasons, I can't rely on SPContext.Current.Web.CurrentUser.

  • Isn't the person who started the featurereceiver and the current user inside the featurereceiver the same person? :) Commented Oct 31, 2012 at 10:31

1 Answer 1


I'm not sure this will work, but I would try this:

public override void FeatureActivated(SPFeatureReceiverProperties properties)
    //Get webapplication
    SPWebApplication webApplication = properties.Feature.Parent as SPWebApplication;
    //Get current user from any sitecollection and rootweb
    SPUser user = webApplication.Sites[0].RootWeb.CurrentUser;
    //Custom code

Since you need the current user, it does not matter where you get it from, so I use an existing sitecollection's rootweb and get the current user from there...


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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