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 FilesCommon FilesMicrosoft SharedWeb Server Extensions12configwss_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

Programmatically add a web part to SharePoint

To add an web part to a page (e.g. default.aspx) in SharePoint use the following code

// Get a reference to a web and a list  
SPSite site = new SPSite("http://localhost:8000");  
SPWeb web = site.OpenWeb();  
SPList list = web.Lists["Tasks"];  
// Instantiate the web part  
ListViewWebPart webpart = new ListViewWebPart();  
webpart.ZoneID = "Left";  
webpart.ListName = list.ID.ToString("B").ToUpper();  
webpart.ViewGuid = list.DefaultView.ID.ToString("B").ToUpper();  
// Get the web part collection  
SPWebPartCollection coll =  web.GetWebPartCollection("default.aspx", Storage.Shared);  
// Add the web part  

Make existing custom column required in sharepoint

Navigate to the

“Document Library Settings” –> “Advanced Settings” –> Check the “Allow management of content types?” radio button to yes and say “OK”

Get back to the settings you will be able to see a new section as “Content Types” Click on the Default content type (or the content type you need to modify).

It will list down all the columns(in the document library)…Select your require column and it will provide you with the following options.

Required (Must contain information)
Optional (May contain information)
Hidden (Will not appear in forms)

Select the Required option to make your column to mandatory contain information.

Deploy an assembly to web applications bin folder using wsp package

You might need to deploy an web part assembly to web applications bin folder rather than the GAC. Read on as how to do that…

Where does an assembly gets deployed is determined by the DeploymentTarget attribute in the solution’s manifest.xml. Setting the attribute to “WebApplication” will deploy it to bin folder of the web application.

Cloud Services: Answering the real world questions

Given the current IT scenario which changes by hour, and where change is the need of the hour we have to deliver more with minimum resources. In other words we need to “DO MORE WITH LESS”; whoa these are not my words :-). These were uttered by Steve Ballmer of Microsoft and just got embedded in my mind. Today everything is being service-oriented and to add to that an economy recovering from a recession has added more fuel in enterprises turning towards Service Offerings. Proliferation of the Internet has given the opportunity to provide real-time access to consumer and business products, software and solutions, without the requirement that an end user personally own the underlying resource. Cloud services are accessed over the Internet via user-friendly web interfaces; they are location independent and do not drill a hole in your pockets 🙂 Why all the hype around cloud computing? Just two words: cheaper & faster. The pay-as-you-go benefits are so compelling that today many have turned towards cloud offerings or are planning towards the same. Given this fact what are the pros & cons, what type of cloud suits me and is the service interoperable with what we use today are some of the intriguing real-world questions which should surface in our minds whilst choosing a cloud offering. I have tried to answer these three questions below i.e.

  1. Security
  2. Public v/s Private
  3. Interoperability

Security is a key area of concern for Cloud Services The key steps to mitigate security concern for cloud services will involve the following

  1. Move non-sensitive data and preferably on a trial basis on the cloud for e.g. Digital content, streaming media, video, music, etc.
  2. Handle the security/encryption at your end instead of leaving it for the service provider
  3. More secure registration process for the cloud to prevent misuse/spamming
  4. Better Auditing and good control should be there on the data hosted on the cloud.
  5. Proper paperwork/agreements need to be put in place in case of highly sensitive data i.e. Terms and Conditions, SLA’s and NOC’s etc
  6. Backup the data regularly at your end instead of relying on the service provider. Though there should be provision of backing up data from the service provider.
  7. Get Information on the infrastructure of the service provider where the data is to be hosted.
  8. Ensure Data Confidentiality and Data isolation for highly sensitive data

Public or Private Cloud: What works best? Public and private clouds both have their own place considering the current economic scenario for that matter. Even if we ignore the financial fact then to lot remains to choose between the private and the public cloud. Both work best for different scenarios. Following are the key differences to make a choice between the two. Public Cloud:

  • For Less sensitive data
  • Low cost
  • Less amount of data to store
  • Store data with Lower Shelf life
  • Less/Compromised security
  • No full control over data or infrastructure
  • No Data Isolation
  • No Maintenance costs

Private Cloud:

  • For sensitive and critical data
  • Costlier than public cloud but can be managed
  • Huge data to store
  • Store data with higher shelf life
  • More secure
  • Total control over data as well as infrastructure
  • Data Isolation
  • Maintenance costs

Interoperability: Cloud Services The basic idea of a cloud platform to be interoperable is to have ability to use various languages, tools to design, develop, debug and deploy applications to the cloud infrastructure standards data access, identity management, deployment packages, ability to seamlessly access services hosted on other clouds (private to public cloud and public cloud to another public cloud) For e.g. Microsoft Azure allows using multiples languages (.NET, PHP, Ruby, Python or Java) and various development tools (Visual Studio or Eclipse) to build applications which run on Windows Azure and/or consume any of the Windows Azure platform offerings from any other cloud or on premise platform. Windows Azure platform also supports multiple Internet protocols including HTTP, XML, SOAP and REST.