How to: Seal a Content Type

Posted Wednesday, March 11, 2009 9:15 AM by CoreyRoth

Sometimes, you want to make absolutely sure that someone can’t go in and change your content type via the Windows SharePoint Services user interface.  If an administrator were to delete or rename columns in your content type this can cause all sorts of issues as things may or may not be prorogated down to the child types.  You might also want to ensure that a content type is only created / modified by using a feature and CAML.   To solve this, a content type can be marked as sealed and it can only be marked as sealed through the object model.  This prevents any casual changes to the content type via the user interface.

The code to seal a content type is pretty simple.  Just get a reference to the particular content type you want to change, set Sealed to true and update the content type.  In my example, I am just changing a content type off the root of the site collection called Test Content Type.   Here is the code.

   14             using (SPSite currentSiteCollection = new SPSite("http://moss-server"))

   15             {

   16                 SPContentType contentType = currentSiteCollection.RootWeb.ContentTypes["Test Content Type"];

   17                 contentType.Sealed = true;

   18                 contentType.Update();

   19             }

Of course there are some things you should know before sealing a content type.  As mentioned before, you will not be able to make any changes in the user interface as you can see below.  You also have to be a site collection administrator to seal the content type.  This means your code has to be executed by a user with appropriate permissions (a console app works fine).  You also need to know that sealed content types are not updated through push-down operations.  So if a change is made in a SPWeb’s content type and a list’s content type beneath it is sealed, that child content type won’t be updated.  You just have to remove all of your seals first.


That is what your content type will look like once it is sealed.  This concept also applies to the SPField object (for Site Columns) as well, the code would be quite similar and also makes use of the Sealed property.  You can also seal content types at the list level as well.  To unseal your content type, just set the sealed property to false and update it again.

Filed under: ,


# re: How to: Seal a Content Type

Tuesday, June 14, 2011 4:14 AM by Siyasanga


Just wanna ask you a small question, on the dilogue box(edit form) of the drop off library where you choose a content type when uploading a document to a recod center, would it be possible to change the dropdown field name from "Content Type" to something else ? When users are choosing a content type to route thier records, I don't want it to say "Content Type", I want it to display whatever I changed it to.

# re: How to: Seal a Content Type

Monday, June 20, 2011 4:14 PM by CoreyRoth

I think you are stuck with whatever the content type's name is in this case.

# R??f??rences pour D??veloppement en SharePoint | BLOC NOTE POUR D??VELOPPEURS SHAREPOINT

Pingback from  R??f??rences pour D??veloppement en SharePoint  | BLOC NOTE POUR D??VELOPPEURS SHAREPOINT

Leave a Comment