MOSS 2010 沙箱解决方案(Sandboxed Solution)

这是一种新的解决方案类型,它出现的目的是让一般的站点集管理员可以部署解决方案,而不是要求场管理员来部署,由于它的这种特殊性,所以,它有很多限制,主要体现在安全性上面。

例如最典型就是在这种解决方案中不能访问到SPFarm对象,因为那是属于场对象,也不能访问诸如http://www.xizhang.com 这种外部的资源。简而言之,它只能访问到自己SPSite里面的一些对象。即便是这样,它仍然能够被限制使用的资源,例如CPU时间和数据库查询的时间等等。这样做的目的就是为了避免一些恶意或者无意的破坏吧

关于Sandboxed Solution,这里还有一篇介绍

http://msdn.microsoft.com/en-us/magazine/ee335711.aspx

那么,我们来观察一下,Sandboxed solution到底有什么不一样呢?请注意下图中的属性,Sandboxed solution设置为true

image

如果对该属性进行切换的话,实际上会有两个不一样的提示

image

image

而我们观察下来,设置为true的话,会在元数据中添加

[assembly: AllowPartiallyTrustedCallers()]

这是什么东东呢?其实很简单,就是表示当前程序集允许部分信任调用。因为沙箱解决方案肯定是部分信任的,按照我的理解,它甚至可能会被单独放在一个应用程序域中执行,来实现安全性的隔离。

关于这个属性,我很早之前也有一个文章专门介绍

http://www.cnblogs.com/chenxizhang/archive/2009/11/09/1599243.html

最后,我们来讨论一下沙箱解决方案与标准解决方案在部署上的不同

1. 标准解决方案(场解决方案),仍然和MOSS 2007那样,是通过stsadm –o addsolution进行部署的

image

image

2. 沙箱解决方案,也可以通过stsadm进行部署,而且如果这样部署的话,那么与标准的解决方案就没有差别。

image

但是通常它更多是通过网站集管理员进行部署。

image

image

点击“上载解决方案”

image

image

image

点击“激活”

image

看起来也很方便,不是吗?

最后,我们要提一下,沙箱解决方案依赖的服务:

image

image

而沙箱解决方案其实是单独运行在下面进程的

•User Code Service
(SPUCHostService.exe)

•Sandbox Worker Process
(SPUCWorkerProcess.exe)

•Sandbox Worker Process Proxy
(SPUCWorkerProcessProxy.exe)

 

image

从细节上来看,它到底能做哪些事情呢

Microsoft.SharePoint Except
SPSite constructor
SPSecurity object
SPWorkItem and SPWorkItemCollection objects
SPAlertCollection.Add method
SPAlertTemplateCollection.Add method
SPUserSolution and SPUserSolutionCollection objects
SPTransformUtilities
Microsoft.SharePoint.Navigation
Microsoft.SharePoint.Utilities Except
SPUtility.SendEmail method
SPUtility.GetNTFullNameandEmailFromLogin method
Microsoft.SharePoint.Workflow
Microsoft.SharePoint.WebPartPages Except
SPWebPartManager object
SPWebPartConnection object
WebPartZone object
WebPartPage object
ToolPane object
ToolPart object

它支持的项目特性包括

Content Types, Site Columns
Custom Actions
Declarative Workflows
Event Receivers, Feature Receivers
InfoPath Forms Services (not admin-appr)
JavaScript, AJAX,
jQuery, Silverlight
List Definitions
Non-visual web parts
Site Pages
SharePoint OnLine
原文地址:https://www.cnblogs.com/chenxizhang/p/1704505.html