To accomplish this, we need to walk through all the web application and determine if the web application is a SSP web application. We can do this by validating if the web application contains a property called “Microsoft.Office.Server.SharedResourceProvider”. The property “” contains a property “AdministrationSiteId”, which is the id of the SSP Administrator Site.
Remark: in most situation we will get two web applications, for a single SSP, with the “Microsoft.Office.Server.SharedResourceProvider” property. This because in most situation we have a Search web application and a MySite web application for a SSP.
The code will look like this:
private StringCollection GetAdminSiteIDs(SPFarm farm) { StringCollection colAdminSites=new StringCollection(); SPWebService webService = farm.Services.GetValue(); foreach (SPWebApplication webApp in webService.WebApplications) { //Check if the web app contains a property Microsoft.Office.Server.SharedResourceProvider, //which indicates it's a SharedResourceProvider. if (webApp.Properties.ContainsKey("Microsoft.Office.Server.SharedResourceProvider")) { object ssp = webApp.Properties["Microsoft.Office.Server.SharedResourceProvider"]; //Get the guid of the Administration Site Guid sspGuid = (Guid)ssp.GetType().GetProperty("AdministrationSiteId").GetValue(ssp, null); //Check if the site is already processed, because for each SSP, we get two SharedResourceProvider //one Search and one MySite. if (!colAdminSites.Contains(sspGuid.ToString())) { colAdminSites.Add(sspGuid.ToString()); } } } return colAdminSites; }
No comments:
Post a Comment