有关可下载书籍的完整列表,请参阅 Office SharePoint Server 2007 的可下载书籍。
实现可插入 SSO 提供程序(从MSDN复制的,怕链接失效)
Posted on 2009-11-16 21:56 程旭圆 阅读(67) 评论(0) 编辑 收藏 所属分类: sharepoint
源文地址:http://msdn.microsoft.com/zh-cn/library/ms566925.aspx
默认情况下,Microsoft Office SharePoint Server 2007 提供 Microsoft Single Sign-On (SSO) Service,用于存储和映射与第三方或后端系统建立连接时所使用的凭据。许多公司已开发了内部凭据存储系统,或者使用 Microsoft Single Sign-On Service 之外的其他解决方案。Office SharePoint Server 2007 提供一种称为可插入 SSO 的机制,作为在两个位置保持凭据映射的替代方法。利用此功能,可以为 Office SharePoint Server 2007 中的标准 SSO 提供程序指定备用 SSO 提供程序。
先决条件
生成 SSO 提供程序之前必须设置环境。此演练假定已设置了 Office SharePoint Server 2007、安装了从 Microsoft 下载中心(该链接可能指向英文页面)下载的 AdventureWorks 2000 数据库副本,并已确保域名为 LITWAREINC。如果使用的是其他域名,则必须调整此演练中的代码示例。 假定已存在下表中显示的域帐户和组。
ExternalPartners InternalSales Tom Tompson Jerry Jones InternalAccess ExternalAccess
有关如何设置数据库和必要的用户帐户的完整说明,请参阅随 AdventureWorks 2000 数据库提供的 README.txt 文件。
域组 域组 域用户 域用户 域用户 域用户
实现单一登录提供程序
替换 Office SharePoint Server 2007 中默认 SSO 提供程序的过程包括实现 Microsoft.SharePoint.Portal.SingleSignon.ISsoProvider接口、将其安装到全局程序集缓存以及向 Office SharePoint Server 2007 注册新的 SSO 提供程序。
只能向 Office SharePoint Server 2007 注册一个 SSO 提供程序。注册新的 SSO 提供程序将替换 Office SharePoint Server 2007 中的默认 SpsSsoProvider类。由于一次只能使用一个 SSO 提供程序,因此建议在使用自定义 SSO 提供程序时停止 Microsoft Single Sign-On Service。
创建功能最简单的 SSO 提供程序将需要实现 ISsoProvider 接口的 GetCredentials 和 GetSsoProviderInfo 方法。本演练介绍如何创建简单的 SSO 提供程序以及使用它通过业务数据目录访问数据。
在本演练中,自定义 SSO 提供程序将 InternalSales 组中的用户映射到 InternalAccess 用户帐户,以便检索 AdventureWorks 2000 数据库中的产品数据。
生成提供程序
本节介绍如何生成并注册简单的 SSO 提供程序,并说明提供程序的异常处理。
下载 若要下载示例提供程序,请参阅 SharePoint Server 2007:软件开发工具包(该链接可能指向英文页面)。 示例
通过创建类库项目,在 Microsoft Visual Studio 2005 中创建 SSO 提供程序程序集。向该项目添加对 Microsoft.SharePoint.Portal.SingleSignon.dll
(
位
于
%ProgramFiles%\\Common
Files\\Microsoft Shared\\web server extensions\\12\\ISAPI 目录)的引
用。实现 ISsoProvider 接口,如下例所示。 C#
using System;
using System.Collections.Generic; using System.Reflection; using System.Text; using System.Web;
using System.Web.Services;
using Microsoft.SharePoint.Portal.SingleSignon;
namespace SampleSSOProvider {
///
/// SimpleSSOProvider
///
public class SimpleSSOProvider: ISsoProvider {
public Application.ApplicationInfo[] GetApplicationDefinitions() {
//NOTE: Used by SpsSsoProvider, not necessary for SimpleSSOProvider throw new NotSupportedException(); }
public Application.ApplicationField[] GetApplicationFields(string AppID) {
//NOTE: Used by SpsSsoProvider, not necessary for SimpleSSOProvider throw new NotSupportedException(); }
public Application.ApplicationInfo GetApplicationInfo(string AppID) {
Application.ApplicationInfo applicationInfo = new
Application.ApplicationInfo(\, \, Application.ApplicationType.GroupWindows, \);
Application.ApplicationInfo applicationInfo = new
Application.ApplicationInfo(\,\,Application.ApplicationType.GroupWindows,\,
(SsoCredentialContents)((Int32)SsoCredentialContents.UserName + (Int32)SsoCredentialContents.Password +
(Int32)SsoCredentialContents.WindowsCredentials)); */
return applicationInfo; }
public Uri GetCredentialManagementURL(string AppID) {
//NOTE: Used by SpsSsoProvider, not necessary for SimpleSSOProvider throw new NotSupportedException(); }
public SsoCredentials GetCredentials(string AppID) {
//Note: Used by SpsSsoProvider, necessary for any SimpleSSO Provider. Implementation discussed in detail in the next section of this topic }
public SsoCredentials GetCredentialsUsingTicket(string Ticket, string AppID) {
//NOTE: Used by SpsSsoProvider, necessary for Simple SSO Provider when used by Excel Services.
//TODO: Implement Ticket management code; currently just return SsoCredentials
return GetCredentials(AppID); }
public string GetCurrentUser() {
//NOTE: Used by SpsSsoProvider, not necessary for SimpleSSOProvider throw new NotSupportedException(); }
public SsoCredentials GetSensitiveCredentials(string AppID) {
//NOTE: Used by SpsSsoProvider, necessary for Simple SSOProvider when used by Excel Services
//TODO: Implement Sensitive Credential method, for sample just returning basic credentials
return GetCredentials(AppID); }
public SsoProviderInfo GetSsoProviderInfo() {
//TODO: Used by SpsSsoProvider, necessary for any SimpleSSOProvider }
public string GetTicket() {