Content Class
Collapse the table of content
Expand the table of content

Content Class

Represents the top-level object for administration of the content sources for a Shared Services Provider's (SSP) search service.


Namespace:  Microsoft.Office.Server.Search.Administration
Assembly:  Microsoft.Office.Server.Search (in Microsoft.Office.Server.Search.dll)

[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public sealed class Content

Use the constructor of the Content class to create a Content object that allows you to access and administer the content sources for an SSP.

For more information about content sources and the new Enterprise Search Administration object model, see Content Sources Overview, Managing Content, and Getting Started with the Search Administration Object Model.

The following code example writes out the full list of content sources for an SSP to a console window. For a complete, step-by-step walkthrough of this sample code, see How to: Retrieve the Content Sources for a Shared Services Provider.


Ensure an SSP is already created.

Project References

Add the following Project References in your console application code project before running this sample:

  • Microsoft.SharePoint

  • Microsoft.Office.Server

  • Microsoft.Office.Server.Search

using System;
using System.Collections;
using System.Text;
using Microsoft.Office.Server.Search.Administration;
using Microsoft.SharePoint;

namespace ContentSourcesSample
    class Program
        static void Main(string[] args)
            Replace <SiteName> with the name of
            a site using the Shared Services Provider.
            string strURL = "http://<SiteName>";
            SearchContext context;
            using(SPSite site = new SPSite(strURL))
               context = SearchContext.GetContext(site);
            Content sspContent = new Content(context);
            ContentSourceCollection sspContentSources = sspContent.ContentSources;
            foreach (ContentSource cs in sspContentSources)
                Console.WriteLine("NAME: " + cs.Name + "  ID: " + cs.Id);

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

© 2015 Microsoft