I'm trying to develop a modification to the branding for all MySites in a farm.

Part of my requirements are to display additional information about the user's MySite - not the logged in user, the user whose page you're on.

Is there a way based on the current context of which MySite you are in to detect whose MySite it is?

I thought it would be SPSite.Owner but that doesn't appear to be correct for non-Admins.


You would need to run the code block as the system account. The safest way to do that is by using the SPUserToken for the system account. Here is an example:

public static string GetSiteOwner(string siteUrl)
    var systemToken = SPUserToken.SystemAccount;
    using (var site = new SPSite(siteUrl, systemToken))
        return site.Owner.LoginName;
| improve this answer | |
  • Since you are already in the context of the site, you can pass in the ID of the site instead of the URL. – John Chapman Dec 5 '13 at 20:15

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.