Sharepoint学习笔记—习题系列--70-576习题解析 -(Q138-Q140)

Question  138
 You are designing a SharePoint 2010 application that will deploy a Web Part assembly. You need to specify which element to add to the solution manifest (manifest.xml) to meet the following requirements:
.The Web Part must retrieve data from an external database but must not require a custom access policy.
.The company’s security policies specify that all SharePoint Web applications must run at minimal trust.
Which approach should you recommend?
A. Add a DwpFile element and an Assembly element specifying a Deployment Target of GlobalAssemblyCache.
B. Add a DwpFile element and an Assembly element specifying a Deployment Target of Web Application.
C. Add a Safe Control element within an Assembly element specifying a Deployment Target of
GlobalAssemblyCache.
D. Add a Safe Control element within an Assembly element specifying a Deployment Target of Web Application.


解析:
 你开发了一个Sharepoint2010应用程序以部署一个Web Part程序集,你需要说明哪个元素可以被添加到解决方案的manifest.xml文件中去,要求如下:
 要求1. 此Web Part可以不需要用户访问策略的支持去从外部数据库获取数据
 要求2. 公司的安全策略要求所有的Sharepoint Web Application必须运行在最小的信任级别。
 你该采用何种方式以满足上述要求呢?
此题的备选项涉及解决方案指令清单(manifest.xml)中的DwpFile元素, Assembly元素与Safe Control元素。
 1. DwpFile元素 :指定解决方案中要包含的 Web 部件文件(.dwp 或 .webpart)。这个元素貌似与本题的安全访问策略方面的需求没什么关系。它仅用来引入相关文件。
 2. Assembly元素: 指定与解决方案的代码访问安全策略关联的程序集。此元素中有DeploymentTarget属性:为可选属性。将程序集复制到由 DeploymentTarget 属性(对于 Web 应用程序)或全局程序集缓存(对于服务器场)指定的目标。可能的值:
 GlobalAssemblyCache   如果程序集是一种场功能,则将其复制到全局程序集缓存。通常,对于已安装到 GAC 的代码,没有任何代码访问安全限制;因此,您将无法从深度防御安全中受益。如果将 Web 部件存储在 GAC 中,则能够在众多的应用程序之间共享 Web 部件。组件通常存储在 C:\WINNT\Assembly 中。
 WebApplication   如果程序集是一种 Web 应用程序功能,则将其复制到虚拟服务器的 bin 目录。这是一个部分可信的位置。默认情况下,从该目录运行的代码具有较低级别的代码访问安全权限。管理员必须明确提升授予 Web 部件的权限,它才能正常工作。由于存在这种控制和深度防御,管理员更希望程序集在 Bin 目录中运行,并使用已知的必需代码访问安全权限集。此外,Bin 目录也是特定于 Web 应用程序的。这样就能够隔离特定于 Web 应用程序的代码。默认情况下,Bin 目录的代码访问安全权限非常低,只允许执行代码。几乎可以肯定的是,必须提升这些权限,才能使程序集正常运行。

3. Safe Control元素:在解决方案的安全控件列表中添加或删除控件程序集。SharePoint 产品和技术的基本假定是“不受信任的用户”可以在运行SharePoint Server 的系统内上载和创建 .aspx 页。虽然应阻止这些用户在 .aspx 页内添加服务器端代码,但应提供一个可供这些不受信任用户使用的已批准控件的列表。在SharePoint Server 中,此列表由安全控件列表提供。
安全控件列表是一个包含特定于 SharePoint 网站的控件和 Web 部件的列表,服务器管理员可以指定在网站内的任何 .aspx 页上调用这些控件和 Web 部件是安全的。
  根据本题的要求,本题明显要用到与安全控件列表相关的选项,即Safe Control元素选项。而根据要求1, 此Web Part可以不需要用户访问策略的支持去从外部数据库获取数据,如果部署到Bin 目录下,则由于Bin 目录的代码访问安全权限非常低,不足以让你去从外部数据库获取数据。而且根据要求2, 公司的安全策略要求所有的Sharepoint Web Application必须运行在最小的信任级别。这就只有把Web Part部署到GAC中以突破Web Application的这个限制。综合起来,本题就需要满组Safe Control元素加上Assembly元素的GlobalAssemblyCache设置 。

因此本题答案应该选 C

参考 
http://msdn.microsoft.com/en-us/library/ms442108.aspx
http://technet.microsoft.com/zh-cn/library/cc262303(v=office.12).aspx
http://msdn.microsoft.com/zh-cn/library/vstudio/ee805045.aspx

 

Question  139
 You are planning an upgrade to a SharePoint 2010 site that contains a feature named MyOriginalCapability. The MyOriginalCapability feature has a version number of 1.0.0.0 but the feature is not yet activated. The new feature is named MyEnhancedCapability and depends on the capabilities of the feature MyOriginalCapability. Your plan must include activation of the MyOriginalCapability feature. You need to plan the deployment of the new feature.
What should your plan for the upgrade include?
A. Incrementing the Version attribute of the MyOriginalCapability feature from 1.0.0.0 to 2.0.0.0
B. Incrementing the Version attribute of the MyOriginalCapability and MyEnhancedCapability features from 1.0.0.0 to 2.0.0.0
C. An Activation Dependency element and Upgrade Actions element in the MyEnhancedCapability feature that references the MyOriginalCapability feature
D. An Activation Dependency element and Upgrade Actions element in the MyOriginalCapability feature that references the MyEnhancedCapability feature


解析:
  你计划升级一个包含了名为MyOriginalCapability 功能的Sharepoint网站,此MyOriginalCapability功能当前版本为1.0.0.0 并且尚未被激活。用于升级的有一个名为MyEnhancedCapability的功能,且此功能依赖于功能MyOriginalCapability,你需要在部署升级此网站时激活MyOriginalCapability功能。 你该如何操作?
  由于后面开发的MyEnhancedCapability功能依赖于老版本的功能MyOriginalCapability,所以它们之间存在激活依赖关系,因此可以直接排除选项A.B.
  而选项D是MyOriginalCapability依赖于MyEnhancedCapability,依赖关系搞反了,所以也排除。
因此本题答案应该选  C

参考 
http://msdn.microsoft.com/zh-cn/library/aa543162(v=office.14).aspx
http://msdn.microsoft.com/zh-cn/library/vstudio/ee231535(v=vs.100).aspx


Question  140
 You are planning an upgrade to a SharePoint 2010 site that contains a feature named MyOriginalCapability. The MyOriginalCapability feature has a version number of 1.0.0.0. You have the following requirements:
.Update the MyOriginalCapability feature to include new fields.
.Deploy a new feature named MyEnhancedCapability that uses the new fields of the MyOriginalCapability feature.
You need to plan the upgrade to meet the requirements. Which approach should you recommend?
A. Increment the Version attribute of the MyOriginalCapability feature to 2.0.0.0, and include an activation dependency with a Minimum Version property of 2.0.0.0 in the MyEnhancedCapability feature.
B. Increment the Version attribute of the MyOriginalCapability feature to 2.0.0.0, and include a Version Range element with End Version set to 2.0.0.0.
C. Increment the Version attribute of the MyEnhancedCapability feature to 2.0.0.0, and include an activation dependency with a Minimum Version property of 2.0.0.0 in the MyOriginalCapability feature.
D. Increment the Version attribute of the MyEnhancedCapability feature to 2.0.0.0, and include a Version Range element with End Version set to 2.0.0.0.


解析:
  你计划升级一个包含了名为MyOriginalCapability 功能的Sharepoint网站,此MyOriginalCapability功能当前版本为1.0.0.0 。你需要满足如下要求:
  要求1.升级MyOriginalCapability功能以包含新的字段
  要求2.部署一个新的名为MyEnhancedCapability的功能,此功能使用前面新添加的字段。
你该如何操作这次升级呢?
  我们知道,功能升级基础结构可自动检测并升级其他功能所依赖的功能,因此,如果向 Feature.xml 文件中添加 <ActivationDependencies> 部分,则无需添加任何特定升级代码即可支持升级被依赖的功能。但是,如果激活依赖关系是尚未激活的可见功能,则必须编写功能升级代码来确保在功能升级期间激活其他功能所依赖的可见功能。
  <ActivationDependency> 元素具有一个 MinimumVersion 属性,可为进行版本管理的功能依赖关系提供支持。在对象模型中,SPFeatureDependency 类具有一个对应的 MinimumVersion 属性,该属性返回在 Feature.xml 文件中指定的值。当您要确保已安装和激活“被依赖”功能的所需版本时,进行版本管理的功能依赖关系将非常有用。
  Microsoft SharePoint Foundation 中的功能版本用于触发功能升级。如果升级功能版本,但未在 Feature.xml 文件中指定任何功能升级逻辑,则当功能升级运行时,它只更新功能的版本号。但是,如果指定了功能升级逻辑,则会执行升级代码,并且还会自动更新版本号。
在更新功能时增加版本号,并根据需要添加相应的功能升级逻辑。即使不需要添加功能升级逻辑,也应增加版本号,以便能够区分在服务器场中部署的功能的版本。
  由于本题是升级MyOriginalCapability 功能,其版本号自然应该从1.0.0.0提高到 2.0.0.0。所以应该排除选项C.D,因为这两个选项升级的是MyEnhancedCapability 功能而非MyOriginalCapability 功能。而功能MyEnhancedCapability是新开发的功能,它与前面的MyOriginalCapability功能存在激活依赖关系,MyEnhancedCapability依赖于新版本(2.0.0.0)的MyOriginalCapability功能中定义的新的字段,所以我们就需要在MyEnhancedCapability的Feature.xml中定义它依赖于功能MyOriginalCapability。所以,选项A为本题正确答案。


因此本题答案应该选  A

参考 
http://msdn.microsoft.com/zh-cn/library/aa543162(v=office.14).aspx
http://msdn.microsoft.com/zh-cn/library/vstudio/ee231535(v=vs.100).aspx
http://msdn.microsoft.com/zh-cn/library/ee538968(v=office.14).aspx

 

posted @ 2014-03-21 11:24  wsdj  阅读(559)  评论(0编辑  收藏  举报