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

Question 75
You are designing a feature for a SharePoint 2010 solution that will be activated by default in your site definition. The values for the configuration settings are based on the particular Web site on which the feature is activated. You have the following requirements:
.Setting the configuration values should not cause downtime.
.The configuration settings must be accessible by other features.
You need to design how the configuration settings will be stored. Which approach should you recommend?
A. Specify the configuration settings using the SPWebConfigModification object.
B. Specify the configuration settings in the property bag for the Web site.
C. Place the configuration settings in the web.config file.
D. Place the configuration settings in a list created by the site definition.

解析:
  你计划创建一个网站定义,此网站定义中包含一个Feature,此Feature默认的会被自动激活, 相关的配置值取决于Feature被激活时所在的网站,也即与网站对象相关联, 并且需要满足如下要求:
  要求1. 在设置配置值时不得造成业务活动的停止
  要求2. 配置值可以被其它功能访问到
  你需要考虑如何保存这些配置值。
  在SharePoint里有许多地方可以存放配置数据。对于SharePoint委托控件(DelegateControl),你可以使用Element manifest文件。对于WebPart,你可以使用.webpart文件。对于全局配置,你可以使用web.config,自定义SharePoint列表,或者SPFarm,SPWebApplication,SPSite,SPWeb和SPList上的属性包。
  首先,根据要求1:在设置配置值时不得造成业务活动的停止,我们可以排除任何关于Web.config的修改,因为任何对此文件的修改都需要重新启动应用才能生效,由此必然导致业务活动停止。所以选项A.C均可排除。
其次选项B. Property Bags, 这是一个存放键-值对配置信息的好地方,Sharepoint的以下层次的对象中均提供了对应的Property Bags。
a. Farm (SPFarm class)
b. Web application (SPWebApplication class)
c. Site collection (SPSite class)
d. Site (SPWeb class)
e. List (SPList class)
   我们可以找到与特定的Web Site对应的Property Bag,使用它来存储配置信息并供其它Feature访问。示例代码如下:
设置配置值
SPSite siteCollection = new SPSite("  ");
SPWeb website = mySite.RootWeb;
website.Properties.Add(" KeyName ", "KeyValue");
website.Properties.Update

读取配置值:
SPSite siteCollection = new SPSite("");
SPWeb website = mySite.RootWeb;
string MyValue = website.AllProperties["KeyName"]);
   所以Property Bag应该是本题的正选。
   至于选项D,把配置信息保存在网站定义所内含的列表中,把列表作为保存配置信息的方式也不是不可,但这种方式并非是基于特定的SPWeb对象,而是基于特定的SPList对象的信息保存方式,与本题的” The values for the configuration settings are based on the particular Web site”所要求的层次级别不符,所以应该被排除。
因此本题答案应该选 B

参考 
http://msdn.microsoft.com/zh-cn/library/gg491705.aspx
http://msdn.microsoft.com/zh-cn/library/ms414322(v=office.14).aspx
http://msdn.microsoft.com/zh-cn/library/gg491706(v=office.14).aspx

 
Question 76
You are designing a SharePoint 2010 solution. Site administrators do not have direct access to the file system on the Web servers. You need to design the solution according to following requirements:
.It must contain a set of Web Parts that receive information from a common collection of configuration data.
.Site administrators must be able to modify the configuration settings for individual sites using the standard SharePoint user interface. Which approach should you recommend?
A. Set the configuration data with the SPWebConfigModification object.
B. Set the configuration data with SharePoint persisted objects.
C. Set the configuration data in the property bag for each Web site.
D. Set the configuration data in a list on each site where the Web Parts are placed.

解析:
  你设计一个Sharepoint2010解决方案,网站管理员无权直接访问Web服务器上的文件系统,你的解决方案需要满足如下要求:
  要求1. 包含一组Web Parts,它们可以从普通的配置信息集中获取信息
  要求2. 网站管理员可以通过Sharepoint用户界面修改各个网站的配置数据。
  你应该采用哪种方法来实现需求。
   由于选项A.B.C均没有提供用户界面来修改相应的配置,而且也不属于普通的配置信息。
   其中选项A是使用 SharePoint Foundation 对象模型来修改 web.config 设置,而根据题干管理员无权直接访问Web服务器上的文件系统。
   选项B通过Persistent Object, 我们知道SPPersistedObject类是用于为对象提供自动序列化其状态值并持久保存以及在需要时获取前面所保存的值并反序列化的相关方法。也即,它属于定义自定义管理设置方面的类。在 Windows SharePoint Services 平台上构建应用程序时,您可能需要创建一个类以定义应用程序的自定义属性设置并提供用于存储这些设置的方法。很明显它不是普通的配置信息,也没有提供用户界面以供修改。
   选项C通过属性包,如我们前面所述,这是一个存放键-值对配置信息的好地方,Sharepoint对SPFarm,SPWebApplication,SPSite,SPWeb和SPList这几个层次的对象均提供了属性包,但我们并没有用户界面来修改它们。
    所以只剩下了选项D.通过保存在列表中的配置信息来达到本题要求。
  因此本题答案应该选 D

参考 
http://msdn.microsoft.com/zh-cn/library/microsoft.sharepoint.administration.sppersistedobject.aspx
http://msdn.microsoft.com/zh-cn/library/gg491706(v=office.14).aspx

 


Question 77
 You are designing a SharePoint 2010 application that connects to an external Microsoft SQL Server database. You have the following requirements:
.Server administrators can add and edit connection strings at the Web application level.
.SharePoint users must not be able to view or modify sensitive data in the connection strings.
.Server administrators can add or change the connection strings declaratively with no custom UI required.
.The connection strings can be modified programmatically without redeploying code.
You need to create a plan to store connection strings for the database within the SharePoint system. Which approach should you recommend?
A. Add or change the connection strings in the web.config file.
B. Use a hierarchical object store configuration approach to store the connection strings.
C. Use a property bag configuration approach to store the connection strings.
D. Use SharePoint lists to store the connection strings.

解析:
   你设计一个Sharepoint2010应用程序,需要连接到Sharepoint系统外部的SQL数据库, 并满足如下要求:
  要求1. 服务器管理员可以在Web Application级别添加,修改数据库连接字符串
  要求2. 必须禁止Sharepoint用户查看和修改连接字符串中的敏感数据
  要求3. 服务器管理员可以通过非定制界面添加或修改连接字符串
  要求4. 可以无需重新部署代码来以可编程方式修改连接字符串
   你需要考虑在Sharepoint系统内采取哪种方式来保存连接字符串以达到上述要求。
   首先根据要求4,我们可以排除选项B. C。其中选项B使用hierarchical object store ,所谓hierarchical object store是指你通过创建继承自SPPersistedObject类的对象类实例来保存关于Farm, Web applications, features等等层次的用户的配置信息。此方法适用于你需要保存比较复杂的对象时使用。而选项C则通过属性包,我们知道Sharepoint对SPFarm,SPWebApplication,SPSite,SPWeb和SPList这几个层次的对象均提供了属性包。不管怎样,选项B.C均需要通过代码编程来应用,而且它们也并没有提供用户界面来修改维护。
   其次,选项D,使用列表保存配置信息,这种方式很明显违背了要求2,因为Sharepiont用户是可以查看到列表信息的,而且它也不满足服务器管理员可以在Web Application级别添加,修改数据库连接字符串这个要求。
    至于选项A,满足本题所有的要求。
 因此本题答案应该选 A

参考 
http://msdn.microsoft.com/en-us/library/ff647766.aspx
http://msdn.microsoft.com/zh-cn/library/microsoft.sharepoint.administration.sppersistedobject.aspx
http://msdn.microsoft.com/en-au/library/ms460914(v=office.12).aspx

 

posted @ 2013-10-18 10:47  wsdj  阅读(593)  评论(0编辑  收藏  举报