Sign In
zevenseas logo
What we offer
Work
Community
Who and where
Communities
Consultancy
Products
With us
Industries
Through us
Get on board
Jobs in the US
Blogs
Stuff
Codeplex
News
Who are we
Where are we
 
Navigation
  • Community Home
  • Blogs Home
  • This Blog's Home
Archives
  • February 2008 (4)
  • March 2008 (22)
  • April 2008 (5)
  • May 2008 (4)
  • June 2008 (3)
  • July 2008 (7)
  • August 2008 (1)
  • September 2008 (3)
Categories
  • Support
  • Code
  • How-to
  • Governance
  • MOSS Search
  • LoveLinks
  • Workflow
RSS Feed Feed your read!

Enumerating through SSP's 

Tags:

As you may have noticed in my previous post I called the SSP in my code using hard-coded text..

string sspname = "SharedServices1";
ServerContext current = ServerContext.GetContext(sspname);

Apart from the fact that I'm a bit ashamed by doing this there was a reason why it was still hard-coded and that was because I couldn't find an easy way to determine if a SPWebApplication was a SSP. All the examples from Microsoft on TechNet show the following snippets when try to open a SSP in code :

SSPGUID2

SSPGUIDReplace

Not very helpful eh ? :) Now with some Googling I found the following blog : Chris Hernandez's Blog with the following post Creating Shared Service Provider (SSP) via command-line options and in the comments section there is the answer to retrieve the SSP Web Applications while looping through the Web Applications. While you are looping there is a certain property in the propertybag that identifies what kind of webapplication it is and apparently for a SSP that key is :

spWebApp.Properties.ContainsKey("Microsoft.Office.Server.SharedResourceProvider")

Now we get all the WebApplications that use the Microsoft.Office.Server.SharedResourceProvider! Next step is to filter the MySites SSP from the Admin SSP ;) And that is pretty easy since we know that the mysites are using their own sitetemplates (MSITEHOST) and the admin page is created using the "OSRV" sitetemplate. By having narrowed down all possibilities we can get the ServerContext of our admin SSP :)

if (spWebApp.Sites[0].RootWeb.WebTemplate == "OSRV")
{
        ServerContext SSP = ServerContext.GetContext(spWebApp.Sites[0]);
} 

So the code in total looks like this :

SPFarm farm = SPFarm.Local;
SPWebService service = farm.Services.GetValue<SPWebService>("");

foreach (SPWebApplication spWebApp in service.WebApplications)
{
    if (spWebApp.Properties.ContainsKey("Microsoft.Office.Server.SharedResourceProvider"))
    {
        if (spWebApp.Sites[0].RootWeb.WebTemplate == "OSRV")
        {
            ServerContext SSP = ServerContext.GetContext(spWebApp.Sites[0]);
        }
    }
}

Hope this helps someone ;)

 
Posted by Robin Meure on 27-Mar-08
0 Comments  |  Trackback Url  |  Link to this post | Bookmark this post with:        
 
Failed to render control: Value does not fall within the expected range.

Comments

Name

Url

Email

Comments

CAPTCHA Image Validation


 

© 2007 Community Kit For SharePoint