Thursday, December 4, 2008

MOSS SSP URL

In order to get the SSP URL of the farm, we can use the following piece of code. This is really helpful if you don't want to hardcode the SSP URL.
   1:  private string getSSPURL()
   2:  {
   3:     string uri = string.Empty;
   4:     ServerContext sc = ServerContext.Default;
   5:     object ssp = sc.GetType().GetProperty("SharedResourceProvider",
                       BindingFlags.Instance | BindingFlags.NonPublic).GetValue(sc, null);
   6:     Guid sspGuid = (Guid)ssp.GetType().GetProperty("AdministrationSiteId").GetValue(ssp, null);
   7:     using (SPSite sspSite = new SPSite(sspGuid))
   8:     {
   9:       uri = sspSite.WebApplication.GetResponseUri(SPUrlZone.Default).AbsoluteUri + "ssp/admin";
  10:     }
  11:     return uri;
  12:  }

1 comment:

Naresh said...

it was good

Post a Comment