My work on this got shoved to the back burner, and I am just now getting
back to it.
I've tried using the impersonation RevertToAppPool class that you
reference, Todd, and I am running into some trouble.
On the line:
foreach(SPWeb web in site.AllWebs) {
I am getting the error:
Cannot complete this action. Please try again.Microsoft.SharePoint at
Microsoft.SharePoint.Library.a.a(String A_0, Object& A_1, Object& A_2,
Object& A_3, Object& A_4, Object& A_5) at
Microsoft.SharePoint.b.a(String[]& A_0, String[]& A_1, Guid[]& A_2,
Int32[]& A_3, String[]& A_4, String[]& A_5, String[]& A_6, String[]&
A_7, Boolean[]& A_8, Int32[]& A_9, Int16[]& A_10, Int16[]& A_11) at
Microsoft.SharePoint.SPWebCollection.b() at
Microsoft.SharePoint.SPWebCollection.Undirty() at
Microsoft.SharePoint.SPBaseCollection.System.Collections.IEnumerable.Get
Enumerator() at
ASI.PortalLibrary.WebParts.MySubSites.RenderWebPart(HtmlTextWriter
output) in c:\documents and settings\bnadler\my documents\visual studio
projects\asinet3\asiportal\webparts\mysubsites.cs:line 74
I am using the following code:
--------------------
protected override void RenderWebPart(HtmlTextWriter output) {
try {
RevertToAppPool reverter = new RevertToAppPool();
reverter.UseAppPoolIdentity();
SPSite site = GetSite();
output.WriteLine (site.Url + "
");
foreach(SPWeb web in site.AllWebs) {
output.WriteLine ("Subsite: <a href=" + web.Url
+ ">" + web.Title + "</a>
");
}
reverter.ReturnToImpersonatingCurrentUser();
} catch (System.Exception exc) {
Text += exc.Message + exc.Source + exc.StackTrace;
}
output.Write(Text);
}
-------------------------