转自:http://www.cnblogs.com/heli/archive/2008/10/15/1312043.html

经本要实践后可行,所以加到自己博中。。。

 

 

在提升权限后对MOSS的list的字段进行更新,出现:对象的当前状态使该操作无效

SPSecurity.RunWithElevatedPrivileges,这个是需要在new SPSite(...)的时候才会去提升权限, 提升的权限是对SPSite, SPWeb的

 

SPSecurity.RunWithElevatedPrivileges(delegate()
        {
           
using (SPSite site = new SPSite("http://localhost"))
            {
               
using (SPWeb web = site.OpenWeb())
                {

                  。。。

                  }

            }

         });

改为:
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPSite site = new SPSite("http://localhost/")
SPWeb web = site.OpenWeb()
});
SPList list = web.Lists["字段名"];
SPListItemCollection items = list.Items;
。。。。
item.Update();

 

就可以了


 

相关文章:

  • 2021-11-30
  • 2022-12-23
  • 2021-06-17
  • 2021-05-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
猜你喜欢
  • 2021-10-26
  • 2021-05-29
  • 2021-11-08
  • 2022-01-10
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案