I'm writing some code where the user should be system account.....like changing the user information list.
but this code has to run for each user ...for that I searched the internet and cud find below solution
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(SPContext.Current.Site.ID))
{
using (SPWeb web2 = site.OpenWeb())
{
//mycode
}}});
but his code throws me this exception
Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed.