Enumerate web applications on a sharepoint farm
To enumerate site collections on a farm:
SPWebService contentService = SPWebService.ContentService;

foreach(SPWebApplication app in contentService.WebApplications) 
{
  if (app.Sites.Count > 0) 
  {
    // pick the first site (root site)
    SPSite rootSite = app.Sites[0];
    
    Trace.WriteLine(site.Url);
  }
}

Published 11 March 2008 10:47 by James

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required)