Thursday, January 13, 2011

HowTo - SharePoint - Build a WSP for an Index Server

I created a solution for SharePoint which must be installed on all the Index Servers in a Farm. So I build a WSP solution with WSPBuilder and I thought that would be it. Because had some code in the feature activate of one of my feature, I thought let’s test the wsp in an environment where my Index Server is a dedicated Index Server (so not a Frontend Server).


To my astonishment, I found out that the WSP was only deployed to all the Frontend servers in my Farm but not to the Index Server :(

Cause

A wsp contains a manifest.xml, which looks like this:

 
 
 
 
 
 
 
 
 


 
When you build a WSP using WSPBuilder, by default the Solution element does not contain a DeploymentServerType attribute, which is the cause of the problem. The DeploymentServerType has the following description:

DeploymentServerType : Optional. Default=WebFrontEnd. This attribute indicates the target of your solution to either a web front end server (WebFrontEnd) or an application server (ApplicationServer).

Solution


Make sure the DeploymentServerType is specified in the manifest.xml. To accomplish this, you need to edit the WSPBuilder.exe.config (in my case in the folder C:\Program Files\WSPTools\WSPBuilderExtensions), and add the attribute DeploymentServerType.


 
 
 

Tuesday, January 11, 2011

HowTo - SharePoint - Get a list of SSPs in code

Ever wanted to get a list of all the Shared Services Provider (SSP) in a SharePoint Farm, for example to retrieve all the search service instances in a Farm?


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;
}