I get the following exception message:
{"Attempted to perform an unauthorized operation."}
at Microsoft.SharePoint.SPSite.get_Owner()
at MySite.Intranet.QuickLinks.MySiteviewpage.GetSiteOwner()
When trying to run the following code:
private string GetSiteOwner()
{
string email = string.Empty;
SPSite siteCollection = new SPSite(SPContext.GetContext(System.Web.HttpContext.Current).Site.Url);
SPWeb site = siteCollection.OpenWeb();
//SPSecurity.RunWithElevatedPrivileges(delegate()
//{
using (site)
{
email = site.Owner.Email; //HITTING THE OWNER CAUSES THE EXCPTION
}
//});
return email;
}
Can anyone help please?