Sometimes I should just read the Microsoft documentation. I just never know when it’s going to provide good code samples or just have a few tautologies.
At any rate, I had some code to loop through subsites that worked fine logged in as a Cotnributor, but wouldn’t work if the user had Read access.
Here’s the code I was using:
SPSite siteCollection = new SPSite(sDomain);
SPWeb site = siteCollection.AllWebs[“usergroup/someone”];
SPWebCollection subSites = site.AllWebs;
foreach (SPWeb subSite in subSites)
{
//blah
}
Now, my “Read” access user had read access to all of the subsites as well as the “usergroup/someone” site… Still I got an “Error: Access Denied” if that web part was on the page. To fix the problem:
SPSite siteCollection = new SPSite(sDomain);
SPWeb site = siteCollection.AllWebs[“usergroup/someone”];
SPWebCollection subSites = site.GetSubwebsForCurrentUser();
foreach (SPWeb subSite in subSites)
{
//blah
}
And I found the answer here: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsite.allwebs.aspx