How to unseal the content type using the object model.
I don't know what one of my users did but somehow they man gage to seal all the content types within their site collection and now cannot edit any content types. When researching about this within TechNet I found this entry: This entry doesn't explain how to correct this. It just states "you cannot change sealed content types through the Microsoft SharePoint Foundation 2010 user interface, and you must be a site collection administrator to unseal the content type using the object model." How exactly would I use the object model to correct all the content types within this site collection? Would I have to use Visual studio 2010 or Power shell? Is there a script already written that I could use? Thank you in advance for any useful information you
July 3rd, 2012 2:25pm

Hi NewSharePointAdmin, Thanks for sharing the post. Im not sure whether you use SharePoint 2010 or SharePoint 2007, in both situations, as the document described, you will not be able to change sealed content types through the user interface, to do this, it needs the site administrator to unseal the content type using the object model. Here is the code snippet, it is for web content type, if the content type is list content type, you just need to find the content type through SPList.ContentTypes. using (SPSite site = new SPSite("http://servername/sitename/")) { using (SPWeb web = site.OpenWeb()) { //SPList list = web.Lists["approvalworkflow Tasks"]; //SPContentTypeCollection ctcoll = list.ContentTypes; SPContentTypeCollection ctcoll = web.ContentTypes; foreach (SPContentType ct in ctcoll) { if (ct.Name.Equals("CustomReport")) { Console.WriteLine(ct.Name + " is sealed:{0} ", ct.Sealed); ct.Sealed = false; ct.Update(); Console.WriteLine(ct.Name + " is sealed:{0} ", ct.Sealed); } } } } Thanks, Qiao Forum Support Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact Wei TechNet Community Support
Free Windows Admin Tool Kit Click here and download it now
July 3rd, 2012 10:43pm

Qiao Wei, Thank you so much for this code. I will give it a try within powershell. I'm curious as to how this user was able to seal all the content types within his site collection. He states he just updated one or two fields using Designer. However, I don't see the option in designer or the GUI to seal a content type.
July 5th, 2012 11:27am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics