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

Question 78
 You are designing an application configuration approach for a custom SharePoint 2010 application. You need to design the application configuration to:
.Store and secure custom configuration settings for the application including connection strings, server names, file paths, and other miscellaneous settings.
.Read and display the settings on the site with an administrative user interface that can be configured using a custom _layouts page.
.Store configuration settings at the farm, Web application, site collection, and site levels as needed.
  You need to design a storage option that is simple and lightweight in structure and programmatically configurable. Which approach should you recommend?
A. Add custom configuration settings to the web.config file and programmatically read this file to display the custom settings.
B. Use a hierarchical object store to save the custom configuration settings and programmatically read it to display the custom settings.
C. Use a property bag to store the custom configuration settings.
D. Use SharePoint lists to store the custom configuration settings.

解析:
  你需要为一个Sharepoint2010应用程序设计一个存取配置信息的方案,需要满足的条件如下:
 要求1. 涉及的配置信息包括连接字符串,服务器名,文件路径以及其它各种各样的设置信息。
 要求2. 通过创建的用于管理的应用程序页,在此页面上读取和显示网站上的相关配置信息。
 要求3  配置信息涉及场,Web Application,网站集以及网站等诸多层次。
  你所提供的保存这些配置信息的方案需要简单,结构不复杂并且支持编程操作。
  我们来分析各选项:
选项A.使用Web.config。首先我们知道,Web.config针对的是Web Application层次及以下的对象,而且创建其管理页面也非常复杂,所以不符合本题要求。
选项B.使用hierarchical object store,前面我们说过所谓hierarchical object store是指你通过创建继承自SPPersistedObject类的对象类实例来保存关于Farm, Web applications, features等等层次的用户的配置信息。此方法适用于你需要保存比较复杂的对象时使用,所以也不符合本题所要求的简单,结构不复杂的要求。
选项C.使用属性包。我们知道Sharepoint对SPFarm,SPWebApplication,SPSite,SPWeb和SPList这几个层次的对象均提供了属性包,通过对应的类对象可以直接使用它们,非常快捷简单,示例代码如下:

using System;
using System.Collections;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities; namespace Test
{
class Program
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("http://localhost"))
{
using (SPWeb web = site.OpenWeb())
{
SPPropertyBag props = web.Properties;
foreach (DictionaryEntry de in props)
{
Console.WriteLine("Key = {0}, Value = {1}", de.Key, de.Value);
}
}
}
Console.ReadLine();
}
}
}

所以选项C符合本题要求。
选项D.使用列表。首先,列表直接就显示在内容页面(Content Page)上,而非要求2所讲的去创建用于管理的应用程序页(Application Page)。其次,使用列表来存储配置Sharepoint场,Web Application级别的信息并不合适,如果要通过代码来实现本题目所涉及的配置内容很显得比较复杂,需要考虑的东西比较多。

因此本题答案应该选C

参考 
http://msdn.microsoft.com/en-au/library/ms460914(v=office.12).aspx
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.properties.aspx

Question 79
You are designing a SharePoint 2010 intranet site. Your design must:
.Specify the manner in which to store and read custom configuration settings.
.Use a standard user interface to allow the configuration settings to be created or changed.
You need to design the solution at the site collection and site levels to meet these requirements. Which approach should you recommend?
A. Use the property bag to store custom configuration settings.
B. Use the hierarchical object store to store custom configuration settings
C. Use SharePoint lists to store the custom configuration settings
D. Add custom configuration settings in the web.config file to display the settings

解析:
 你需要设计一个Sharepoint2010内部网站满足如下要求:
 要求1. 确定以哪种方式存取用户配置信息
 要求2. 使用标准的用户界面以支持创建和修改配置信息
 你需要在网站与网站集层次满足以上要求。
 由于本题要求使用标准的用户界面以支持创建和修改配置信息,比较各备选项就发现只有使用列表才能符合要求了,因为Property bag与hierarchical object store均未提供用户界面进行修改,它们都需要通过代码编程实现。Web.config也不是标准的用户界面所能操纵的,况且它主要是针对Web Application级别的配置设置。
因此本题答案应该选 C

参考 
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.meetings.propertybag.aspx
http://msdn.microsoft.com/en-au/library/ms460914(v=office.12).aspx
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.properties.aspx

Question  80
You are designing a SharePoint 2010 farm implementation that will include an extranet zone that will employ forms-based authentication (FBA). The plan must:
.Specify how farm administrators will manage modifications to the configuration settings for the FBA within each Web application.
.Support granular modifications to the individual Web applications.
.Include a process to apply the modifications to the SharePoint configuration database.
.Specify a process to deploy the changes throughout the server farm by propagating the changes to all Web frontend servers.
  You need to create a software configuration management plan for the farm that meets all these requirements. Which approach should your plan recommend?
A. Create a feature that contains code to read, modify, and save the configuration setting for the SPWebApplication object for each Web application. Save the settings in the hierarchical object store by creating a SPPersistedObject class to store the configuration.
B. Create a feature that contains code to modify the configuration settings to the web.config file for each Web application. Then propagate the changes programmatically by implementing the SPWebConfigModification class.
C. Build a custom list for each Web application that stores the required configuration information. Create a custom workflow that uses the Set Field in Current Item action to synchronize the settings in the list with the configuration database and the Web servers.
D. Build the required changes declaratively by creating an XML extension containing the settings needed. Deploy the file to the 14\Config directory. Then use the Stsadm copyappbincontent command to merge these changes with the existing web.config file.

解析:
  你负责设计一个包含外部区域(支持表单认证FBA)的Sharepoint2010场应用,需要满足如下要求:
  要求1. 指明场管理员如何针对每个Web Application维护用于表单认证的配置设置。
  要求2. 支持对各个Web Application分别进行修改
  要求3. 实现把上述的修改传播到场内所有的WFE服务器上
   你需要针对Sharepoint场来制定一个软件配置管理方案以满足上述所有要求。
下面我们来分析各备选项:
选项A. Create a feature that contains code to read, modify, and save the configuration setting for the SPWebApplication object for each Web application. Save the settings in the hierarchical object store by creating a SPPersistedObject class to store the configuration.
  我们知道,Web.config与Hierarchical object store均是针对Web Application层次的配置存储途径,Hierarchical object store主要用于为第三方应用程序通过创建继承自SPPersistedObject类的对象来实现存取配置信息提供一个应用框架。实例化 SPPersistedObject 的对象保留在 SharePoint 2010 配置数据库中。而我们知道Sharepoint使用配置数据库来存储服务器场中服务器的配置和网站映射信息。每个服务器场只能有一个配置数据库。 由此就无法实现本题的要求3,即把上述的修改传播到场内所有的WFE服务器上。所以本选项被排除

选项B. Create a feature that contains code to modify the configuration settings to the web.config file for each Web application. Then propagate the changes programmatically by implementing the SPWebConfigModification class.
   通过Web.config来实现,我们知道SharePoint Foundation用到了大量的 web.config 文件。Sharepoint中的每个 Web Application都对应一个文件,并且每台前端 Web 服务器中包含每个这些文件的副本。为了更加轻松地自定义 web.config 文件,SharePoint Foundation 提供了两种更改方式。第一种方式是通过创建包含一组 web.config 修改的 XML 文件以声明方式注册 web.config 项,此方式会把所有WebApplication的web.Config都修改掉。第二种就是使用 SharePoint Foundation 对象模型来修改 web.config 设置。
   我们可以以编程方式添加和删除 Web.config 设置,修改 web.config 设置的一种方法是使用 Microsoft.SharePoint.Administration 命名空间的 SPWebConfigModification 类,这使得您能够动态地对实体进行注册。这些修改保留在配置数据库中,在那里,它们充当一种虚拟 web.config,后者其实上充当 SharePoint Foundation Web 应用程序的 .config 文件堆栈的最后一层。在调用 SPWebService.ApplyWebConfigModifications 方法时,所做更改才会生效。
调用 ApplyWebConfigModifications 方法将安排一个计时器作业以在整个服务器场中部署更改【也就是本题要求3所指的”传播”效果】。若要将 web.config 修改应用于特定的 Web 应用程序,请将此修改添加到 Web 应用程序的 web.config 修改集 (WebConfigModifications) 中。例如,您可以使用 oWebSite.Site.WebApplication.WebConfigModifications.Add(MyModification) 将 web.config 修改添加到特定网站的父 Web 应用程序中。即使是将 web.config 修改添加到单个 Web 应用程序,您也仍旧必须调用 ApplyWebConfigModifications。
    由上面分析可以看出,选项B是本题想要的答案。

选项C. Build a custom list for each Web application that stores the required configuration information. Create a custom workflow that uses the Set Field in Current Item action to synchronize the settings in the list with the configuration database and the Web servers. 
  列表并不是用来存储Web Application级别配置信息的合理架构,所以直接排除。

选项D. Build the required changes declaratively by creating an XML extension containing the settings needed. Deploy the file to the 14\Config directory. Then use the Stsadm copyappbincontent command to merge these changes with the existing web.config file.
    本选项虽然使用了Web.config,但它的操作方式是将配置修改影响到所有的Web.config,而满足不了本题要求2所提的:支持对各个Web Application分别进行修改。所以也被排除。

因此本题答案应该选 B

参考 
http://msdn.microsoft.com/zh-cn/library/bb861909(v=office.14).aspx
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spwebapplication.aspx
http://dsen-25.blogspot.com.au/2011/08/hierarchical-object-store-in-sharepoint.html
http://msdn.microsoft.com/zh-cn/library/bb677365(v=sql.105).aspx

上一篇:HDU 3081 最大流+并查集


下一篇:csu 1756(数论+去重)