How to identify insecure web part / control

When I try to edit a page on a SharePoint site, I get an error. Using WinDbg I see that the actual error is:

Microsoft.SharePoint.ApplicationRuntime.SafeControls + UnsafeControlException

It looks like I have a control on the page that is not included in the <SafeControls> section of the web.config. I looked at the aspx file for the page, but I can't see any controls that are not referenced in the web.config.

Digging a little deeper (and using Sosex.dll ) I got the following data from the callstack which results in an error:

0:013> !mframe 03
0:013> !mdv
Frame 0x3: (Microsoft.SharePoint.ApplicationRuntime.SafeControls.GetTypeFromGuid(System.Guid)):
[A0]:this:0xc00c03e8 (Microsoft.SharePoint.ApplicationRuntime.SafeControls)
[A1]:guid:{ef2d8253-a451-56da-be1d-5f32d5227173} VALTYPE (MT=0000064278430ea8, ADDR=000000000308caa0) (System.Guid)
[L0]:null (System.Type)
[L1]:0x633c50 (System.String) STRVAL=The type could not be found or it is not registered as safe.
[L2]:null (System.Type)

      

So, it looks like I found the GUID of the control ([A1]) that is causing the problem. However, I don't know how to find which control this GUID is referring to. Should there be a table somewhere in SQL Server where this information is stored? I already tried dbo.WebParts choosing against tp_ID with GUID but couldn't find anything. Think I am missing something?

+2


source to share


3 answers


Be there! Back slowly from SQL Server;)

The first thing to look at is the difference between a private web part and a remote web part .

Closed is a menu operation that you get when you are not in Page Mode Editing, and it simply hides the web part from view. SharePoint is still trying to load its assembly and you will get errors if there is no corresponding secure management record.



If this is a problem, then an easy way to remove it is to put it ? contents = 1 to the end of the url and the page will open in maintenance mode.

Hope this is helsp!

+2


source


To handle web parts programmatically, you can use SPLimitedWebPartManager

See this article for an idea of ​​how to remove or find a web page from a page.



With a debugger, it's enough to just list all these web pages and just see the corresponding DisplayTitle for your ID.

0


source


Using reflector, I found that they generate a GUID for each control:

internal static Guid GetTypeId(MD5HashProvider md5Provider, Type type, string assemblyName)
{
    byte[] bytes = new UnicodeEncoding().GetBytes(assemblyName + "|" + type.FullName);
    return new Guid(md5Provider.GetHash(bytes));
}

      

So, if you really want to find it, go through each assembly, enter and match the GUID. Good luck. I have the same problem. I am planning on removing one control at a time until I commit it.

0


source







All Articles