[SharePoint 2010 的那些事儿 – Secure Store Service]SharePoint 2010中的单点登录
2011-02-01 02:19
405 查看
在SharePoint 2007时代我们可以通过Microsoft Single Sign-on Service来实现单点登录,但到了SharePoint 2010中不再有Single Sign-on这个服务了,取而代之的则是Secure Store Service简称SSS。与以前的SSO一样,SSS也提供了一个数据库实例来保存用于访问某些外部应用程序或外部数据源的用户凭据信息,所不同的是我们不仅可以使用SSS中保存的凭据信息来实现单点登录,同时BDC、Excel Service等服务应用程序现在也可使用SSS中保存的凭据来访问外部数据源。接下来的内容中小弟我将对如何使用SSS实现单点登录进行详细的说明。
与2007相同的是在SP 2010中要实现单点登录依然需要我们写代码来实现,不过在这之前还需要对场中的SSS服务进行初始配置。
对SSS进行初始配置
首先进入SharePoint 2010管理中心,在应用程序管理页面选择管理服务应用程序。
代码
与2007相同的是在SP 2010中要实现单点登录依然需要我们写代码来实现,不过在这之前还需要对场中的SSS服务进行初始配置。
对SSS进行初始配置
首先进入SharePoint 2010管理中心,在应用程序管理页面选择管理服务应用程序。
代码
using System; using System.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using Microsoft.SharePoint; using Microsoft.Office.SecureStoreService.Server; using Microsoft.BusinessData.Infrastructure.SecureStore; namespace SP2010SingleSignOnWebPart.SingleSignOnWebPart { public partial class SingleSignOnWebPartUserControl : UserControl { protected void Button1_Click(object sender, EventArgs e) { string m_userName = string.Empty; string m_password = string.Empty; string m_html = string.Empty; string m_appId = "163Mail"; SecureStoreProvider m_provider = new SecureStoreProvider(); SPSite m_site = SPContext.Current.Site; SPServiceContext m_serviceContext = SPServiceContext.GetContext(m_site); m_provider.Context = m_serviceContext; try { SecureStoreCredentialCollection m_sscc = m_provider.GetCredentials(m_appId); foreach (SecureStoreCredential ssc in m_sscc) { switch (ssc.CredentialType) { case SecureStoreCredentialType.Generic: break; case SecureStoreCredentialType.Key: break; case SecureStoreCredentialType.Password: m_password = ToClrString(ssc.Credential); break; case SecureStoreCredentialType.Pin: break; case SecureStoreCredentialType.UserName: m_userName = ToClrString(ssc.Credential); break; case SecureStoreCredentialType.WindowsPassword: break; case SecureStoreCredentialType.WindowsUserName: break; default: break; } } m_html += "<script>"; m_html += string.Format("window.location.href='http://reg.163.com/login.jsp?url=&type=1&product=&savelogin=&outfoxer=&domains=&syscheckcode=4ecd8fe3803494cff0df5414f321fd5f9afa4c78&username={0}%40163.com&password={1}&Submit='", m_userName, m_password); m_html += "</script>"; Response.Write(m_html); } catch (Exception ex) { Response.Write("<script>window.location.href= '/_layouts/SecureStoreSetCredentials.aspx?TargetAppId=" + m_appId + "';</script>"); } } internal string ToClrString(SecureString p_string) { var m_ptr = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(p_string); try { return System.Runtime.InteropServices.Marshal.PtrToStringBSTR(m_ptr); } finally { System.Runtime.InteropServices.Marshal.FreeBSTR(m_ptr); } } } }
相关文章推荐
- [SharePoint 2010 的那些事儿 – Secure Store Service]SharePoint 2010中的单点登录
- SPS2010实现单点登录(Secure Store Service的使用)
- [SharePoint 2010 的那些事儿 – Excel Service]初识 Excel Service JavaScript OM
- Sharepoint 2013 Secure Store Service
- Sharepoint 2013 通过Secure Store Service获取用户信息
- [SharePoint 2010 的那些事儿 – Excel Service]如何与EWA WebPart进行交互
- 配置Secure Store Service (SharePoint Server 2010)显示“无法获取主密钥”
- [SharePoint 2010 的那些事儿 – Excel Service]如何修改Excel工作表的值
- Sharepoint 2013 Secure Store Service
- SharePoint 2013 SSO-Secure Store Service在实际案例中的应用
- [SharePoint 2010 的那些事儿-升级篇]In-Place Update 就地升级
- SharePoint 2010 BI(2):使用Visio Service
- 从其它系统登录到SharePoint 2010系统的单点登录
- SharePoint 2010 服务应用程序(Service Application)架构(1) 推荐
- 使用Secure Store Service连接数据库
- SharePoint 2010 服务应用程序(Service Application)架构(2)
- SharePoint 2010 服务应用程序(Service Application)架构(3)
- SharePoint 2010 Search Service: Unable to connect to the search service 的问题处理
- [SharePoint 2010 的那些事儿 – InfoPath]通过REST Web Service在表单中嵌入地图
- [SharePoint 2010 User Profile Service] 关于User Profile Service的一些提示