SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Isn't the person who started the featurereceiver and the current user inside the featurereceiver the same person? :) – Ruben Herman Oct 31 '12 at 10:31
up vote 2 down vote accepted

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

share|improve this answer
That appears to work indeed! Thank you! – Spongeroberto Squarepantalones Oct 31 '12 at 10:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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