Creating a List Mashlets Web Part using Presto Connector for C#: Example 3

 Rather than applying a Full trust level we will create a custom security policy which extends the standard SharePoint WSS_Minimal trust level.

Navigate to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\config\, the default location for SharePoint security policy files, and create a copy of of WSS_MinimalTrust.config, name it something likePresto_WSS_MinimalTrust.config

Open Presto_WSS_MinimalTrust.config and create a copy of the PermissionSet named SPRestricted, rename the copy asPresto and append a new IPermissionSet element which defines a WebPermission setting:

<PermissionSet class="NamedPermissionSet" version="1" Name="Presto">
     <IPermission class="AspNetHostingPermission"
         version="1"
         Level="Minimal"
     />
     <IPermission class="SecurityPermission"
         version="1"
         Flags="Execution"
     />
     <IPermission class="WebPartPermission"
         version="1"
         Connections="True"
     />
     <IPermission class="SharePointPermission"
         version="1"
         ObjectModel="True"
     />
     <IPermission class="WebPermission"
         version="1"
         Unrestricted="True"
     />
</PermissionSet>

Insert, as the first child, a new CodeGroup element which uses a UrlMembershipCondition to reference all the Jackbe.*.dlls inbin:

<CodeGroup
      class="UnionCodeGroup"
      version="1"
      PermissionSetName="Presto">
      <IMembershipCondition
            class="UrlMembershipCondition"
            version="1"
            Url="$AppDirUrl$/bin/Jackbe*dll"
      />
</CodeGroup>

Having saved the updated config file, we must now update web.config to reference this file. Locate the SecurityPolicyelement and add a the following new trustLevel child element:

<trustLevel
     name="Presto_WSS_Minimal"
     policyFile="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\config\Presto_WSS_MinimalTrust.config"
/>

Finally, we must reset the server so that it picks up this config change. Open a console window and enter the commandiisreset.

Now we are ready to add the new Web Part to the SharePoint Web Part gallery.

0
Your rating: None