I’am trying to retrieve all site and subsite in sharepoint but i get access denied.
I read about to use GetSubwebsForCurrentUser() property, but i get the same message.
My code is the next
foreach (SPWebApplication webApp in SPWebService.ContentService.WebApplications)
{
foreach (SPSite siteCollection in webApp.Sites)
{
foreach(SPWeb web in siteCollection.RootWeb.GetSubwebsForCurrentUser())
{
dropDownSite.Items.Add(web.Url);
}
}
}
please i need help! Thanks!
You will probably need to call
SPSecurity.RunWithElevatedPrivileges(delegate())You could do an inline delegate if you wish, something like: