Monday, September 21, 2009

SharePoint 2007 | List All Web Applications in Farm

So you think it would be cool to have a dropdownlist with all web applications from your SharePoint Farm Server?

using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;

(...)

SPFarm spf = SPFarm.Local;
SPWebService spws = spf.Services.GetValue("");

foreach (SPWebApplication spwa in spws.WebApplications)
{
ddl_MyWebs.Items.Add(spwa.DisplayName);
}

My thanks go to Brian for this great code

No comments:

Post a Comment