签入文档时,我在 ItemCheckingInEvent 中执行Web服务。在开发中,没有问题。我部署了应用程序,结果发现我没有足够的权限来读取配置文件。我的代码读取配置文件以创建WCF代理。真正的问题是,如果我使用 SPSecurity.RunWithElevatedPrivileges 函数,如何从函数返回?

例如:

SPSecurity.RunWithElevatedPrivileges(delegate()
{

      // exec service call

});

// need data from service call here
有帮助吗?

解决方案

只需在提升的委托之前声明您的工作对象,并将其分配到:

object myServiceData = null;

SPSecurity.RunWithElevatedPrivileges(delegate()
{
      myServiceData = DoServiceStuff();
});

//do things with myServiceData
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top