If you use the SPSite.AllWebs Access Denied message, a message appears! This statement is only valid if the current user is the site collection administrator.
So, for all users, this function receives all sites and subsites.
public static IEnumerable<SPWeb> DescendantSites(this SPWeb input) { foreach (SPWeb web in input.GetSubwebsForCurrentUser()) { yield return web; foreach (var subnode in web.DescendantSites()) yield return subnode; } }
juan_dvd
source share