Wednesday, June 12, 2013

SandBoxSolution - Full trust proxies in SharePoint 2010

Sandboxed solution is completely isolated to its site collection only a subset of the Microsoft.SharePoint object model is avail - Only objects that operate within the current site collection are available.

Sandbox runs within process - Sandbox Worker Process (SPUCWorkerProcess.exe)

sandbox worker process makes sure to enforce the limits of a Code Access Security (CAS) policy on the contents of the solution
  • SharePointPermission.ObjectModel
  • SecurityPermission.Execution
  • AspNetHostingPermission.Level = Minimal
A Proxy Class has to be deployed at Farm level and can be used by everybody within the farm.
The full trust proxy solution exists of two classes:
The first class inherits from SPProxyOperation, the second class inherits from SPProxyOperationArgs.
Both of these are located in the Micorosft.SharePoint.UserCode namespace.
The class which inherits from SPProxyOperation implements the actual operation the full trust proxy solution has to perform.
The class which inherits from SPProxyOperationArgs defines the arguments which will be passed to the operation. 

When you redeploy your full trust proxy solution you have to restart the User Code Service

Sandbox solution runs under SPUserWorkerProcess.exe, but the full-trust proxy runs under SPUserCode.exe.

…To restart go to the Central Administration, Application Management, Manage services on server and find the Microsoft SharePoint Foundation Sandboxed Code Service. Stop and start this service again. Another option is to use “net stop SPUserCodeV4″, and start it again by using “net start SPUserCodeV4″.

Use SPUtility.ExecuteRegisteredProxyOperation to call code in full trust proxy.


No comments:

Post a Comment