I'm trying to write a custom web service that returns all webs that a
user has full control of. However, I get a "Server was unable to
process request. --> Operation is not valid due to the current state
of the object." error. This is what the code looks like:
[WebMethod]
public string GetWebs()
{
string info = string.Empty;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(SPContext.Current.Site.ID))
{
Type groupType = typeof(SPGroup);
Type userType = typeof(SPUser);
// site.AllWebs seems to generate the error; all code in the
// foreach loop is commented out.
foreach (SPWeb web in site.AllWebs)
{
} // end foreach web
site.RootWeb.Dispose();
} // end using
});
return info;
}
The event log was initially reporting a DCOM error with IIS WAMREG,
but I gave the account launch and local activation rights. Now, I get
no clue from the event log.
Does any one have an idea of what's going on?