One of our partners faced a problem that I think we will eventually see occurring frequently with external customers, so I thought to document the problem’s symptoms and a possible fix..
<Elements xmlns="<a href="http://schemas.microsoft.com/sharepoint/"">http://schemas.microsoft.com/sharepoint/"</a>> <Module Name="MyModule" Url="Shared Documents" > <File Url="Test.aspx" Type="GhostableInLibrary" > <AllUsersWebPart WebPartZoneID="Header" WebPartOrder="1"> <![CDATA[ <?xml version="1.0" encoding="utf-8"?> <WebPart xmlns:xsd="<a href="http://www.w3.org/2001/XMLSchema"">http://www.w3.org/2001/XMLSchema"</a> xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance"">http://www.w3.org/2001/XMLSchema-instance"</a> xmlns="<a href="http://schemas.microsoft.com/WebPart/v2"">http://schemas.microsoft.com/WebPart/v2"</a>> <Title>A Test</Title> <FrameType>Default</FrameType> <Description /> <IsIncluded>true</IsIncluded> <ZoneID>Header</ZoneID> <PartOrder>0</PartOrder> <FrameState>Normal</FrameState> <Height>222px</Height> <Width></Width> <AllowRemove>false</AllowRemove> <AllowZoneChange>false</AllowZoneChange> <AllowMinimize>false</AllowMinimize> <IsVisible>true</IsVisible> <DetailLink /> <HelpLink /> <Dir>Default</Dir> <PartImageSmall /> <MissingAssembly /> <PartImageLarge /> <IsIncludedFilter /> <ID>g_A4D135E1_0834_4b88_AA94_E7EC5BA80E93</ID> <Assembly>MyWebPartAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</Assembly> <TypeName>MyWebParts.WebPart1</TypeName> </WebPart> ]]> </AllUsersWebPart> </File> </Module> </Elements>
<Elements xmlns="<a href="http://schemas.microsoft.com/sharepoint/"">http://schemas.microsoft.com/sharepoint/"</a>>
<Module Name="MyModule" Url="Shared Documents" >
<File Url="Test.aspx" Type="GhostableInLibrary" >
<AllUsersWebPart WebPartZoneID="Header" WebPartOrder="1">
<![CDATA[
<?xml version="1.0" encoding="utf-8"?>
<WebPart xmlns:xsd="<a href="http://www.w3.org/2001/XMLSchema"">http://www.w3.org/2001/XMLSchema"</a> xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance"">http://www.w3.org/2001/XMLSchema-instance"</a> xmlns="<a href="http://schemas.microsoft.com/WebPart/v2"">http://schemas.microsoft.com/WebPart/v2"</a>>
<Title>A Test</Title>
<FrameType>Default</FrameType>
<Description />
<IsIncluded>true</IsIncluded>
<ZoneID>Header</ZoneID>
<PartOrder>0</PartOrder>
<FrameState>Normal</FrameState>
<Height>222px</Height>
<Width></Width>
<AllowRemove>false</AllowRemove>
<AllowZoneChange>false</AllowZoneChange>
<AllowMinimize>false</AllowMinimize>
<IsVisible>true</IsVisible>
<DetailLink />
<HelpLink />
<Dir>Default</Dir>
<PartImageSmall />
<MissingAssembly />
<PartImageLarge />
<IsIncludedFilter />
<ID>g_A4D135E1_0834_4b88_AA94_E7EC5BA80E93</ID>
<Assembly>MyWebPartAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</Assembly>
<TypeName>MyWebParts.WebPart1</TypeName>
</WebPart> ]]>
</AllUsersWebPart>
</File>
</Module>
</Elements>
Well, it’s hard to call it a problem, it’s a design decision we took. Sharepoint at that first page visit, will do the WebPart import into the page, and as it’s a reader who tries to do the import, it fails.
The failure (as the text tells) is because the logged in user doesn’t have AddAndCustomizePages permission, this error pops up in different places but the reason for that specific one is because MyWebPart1 is not marked as SafeAgainstScript=True (I’ve a post about it here). You don’t want to mark just any WebPart as SafeAgainstScript=True because that can expose you, the site and your users to danger. At this point you have 3 options:
That’s it for now… stay tuned!