30 Sep 2011

Full Trust Proxies SharePoint

The architecture of sandboxed solutions provides the capability to utilize external full-trust proxies, deployed and authorized by farm administrators so that you can provide full-trust code execution capabilities to sandboxed solutions.

Full-trust proxies can be installed by farm administrators only,

Implementing a Full-Trust Proxy

Namespace: Microsoft.SharePoint.UserCode
Base Class: SPProxyOperation base abstract class

public class RetrieveNWindCustomers : SPProxyOperation {
public override object Execute(SPProxyOperationArgs args) {
// Operation that require more security rights compar to a SandBox Solution
}



 


After implementing the proxy, you need to define a feature with a feature receiver that will
use some custom code for registering it in the farm


 


Consuming the Full-Trust Proxy


Example: A Web Part that employs the full-trust proxy


   1:  public class ShowNWindCustomers : WebPart {
   2:  protected override void CreateChildControls() {
   3:  RetrieveNWindCustomersArgs args =
   4:  new RetrieveNWindCustomersArgs() {
   5:  SqlConnectionString = this.SqlConnectionString,
   6:  };
   7:  // Invoke the proxy operation
   8:  DataSet data = SPUtility.ExecuteRegisteredProxyOperation(
   9:  typeof(MYPROXYCLASSNAME).Assembly.FullName,
  10:  typeof(RetrieveNWindCustomers).FullName,
  11:  args) as DataSet;
  12:  // ....................
  13:  }
  14:  }


No comments:

Post a Comment