Home > security, SharePoint > Create your own Custom Code Access Security Policy for SharePoint web part

Create your own Custom Code Access Security Policy for SharePoint web part

1.First, goto the CONFIG folder in your 12 Hive.There you will see the two standard security config files:
wss_mediumtrust.config and wss_minimaltrust.config.

2. Copy the WSS_Minimal policy file stored at “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\config\wss_minimaltrust.config”

3. Rename to MyCustomPolicy_Minimal.config

4. Open and added the following entries under the code group section:

5.First, locate the NamedPermissionSets section.  At the bottom of this section, add the following:

6. In the config file, find the CodeGroup tags.  There may be a few of them.  The first one will be something like:


Below it are other CodeGroups.  We are going to add a new CodeGroup in this section for our assembly.

So copy the following code:

Paste this just after the FirstMatchCodeGroup CodeGroup.  This is important that you paste it after the “FirstMatchCodeGroup” since all of the other CodeGroups are “UnionCodeGroups”.  This is worth noting because depending on the type of UnionCodeGroup, its criteria may be broad enough to encompass your new assembly and once it is accepted by a CodeGroup it stops looking.  So if you put your new CodeGroup last, odds are that your changes will never be seen.  So, make sure it’s the first CodeGroup.

7. Save your config file cause we’re done with it.

8. In the web.config, add

to the securityPolicy section and change


9. Save the web.config and do issreset

Categories: security, SharePoint
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: