MOSS与业务系统的集成 之 单点登录
2008-08-05 16:35
411 查看
前面MOSS与业务系统的集成 之 自定义Membership实现Forms方式验证文章中,我们实现了两系统的用户集成,下面要解决的是两系统间的单点登录问题。
部署在两台不同的服务器上的系统,要实现单点登录,最好的办法就是使用Cookie共享来实现了。只要将两系统使用同一根域名,并且用户保存用户登录票据的Cookie名称,以及Cookie加解密密钥一致即可。
业务系统的写cookie方式
1 protected static void WriteCookie(string userName, bool isPersistent)
2 {
3 FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
4 1,
5 userName,
6 DateTime.Now,
7 DateTime.Now.AddMinutes(80),
8 isPersistent,
9 userName,
10 FormsAuthentication.FormsCookiePath);
11 // Encrypt the ticket.
12 string encTicket = FormsAuthentication.Encrypt(ticket);
13 HttpCookie myCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
14
15 //如果用户使用域名访问ADC,则在cookie上增加域名信息
16 if (IsValidDomain(HttpContext.Current.Request.Url.Host))
17 {
18 myCookie.Domain = FormsAuthentication.CookieDomain;
19 }
20
21 if (isPersistent)
22 {
23 myCookie.Expires = ticket.Expiration;
24 }
25 // Create the cookie.
26 HttpContext.Current.Response.Cookies.Add(myCookie);
27 }
28
29 protected static bool IsValidDomain(string strIn)
30 {
31 string strPattern = @"^\w+([-.]\w+)*\.\w+([-.]\w+)*$";
32 return System.Text.RegularExpressions.Regex.IsMatch(strIn, strPattern);
33 }
34
业务系统的web.config修改
<!--Cookie名称与根域名需一致-->
<authentication mode="Forms">
<forms name="CookieName" domain=".domain.com" path="/" ></forms>
</authentication>
Moss站点的web.config修改
<!--将MOSS站点web.config中machineKey配置复制到业务系统中,两系统保持一致即可 -->
<machineKey validationKey="C57043728999BCF9537BA55F5978F50722C91B26A0F9D34F"
decryptionKey="C57043728999BCF9537BA55F5978F50722C91B26A0F9D34F"
validation="SHA1" />
<!--Cookie名称与根域名也需一致-->
<authentication mode="Forms">
<forms name="CookieName" domain=".domain.com" path="/" ></forms>
</authentication>
部署在两台不同的服务器上的系统,要实现单点登录,最好的办法就是使用Cookie共享来实现了。只要将两系统使用同一根域名,并且用户保存用户登录票据的Cookie名称,以及Cookie加解密密钥一致即可。
业务系统的写cookie方式
1 protected static void WriteCookie(string userName, bool isPersistent)
2 {
3 FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
4 1,
5 userName,
6 DateTime.Now,
7 DateTime.Now.AddMinutes(80),
8 isPersistent,
9 userName,
10 FormsAuthentication.FormsCookiePath);
11 // Encrypt the ticket.
12 string encTicket = FormsAuthentication.Encrypt(ticket);
13 HttpCookie myCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
14
15 //如果用户使用域名访问ADC,则在cookie上增加域名信息
16 if (IsValidDomain(HttpContext.Current.Request.Url.Host))
17 {
18 myCookie.Domain = FormsAuthentication.CookieDomain;
19 }
20
21 if (isPersistent)
22 {
23 myCookie.Expires = ticket.Expiration;
24 }
25 // Create the cookie.
26 HttpContext.Current.Response.Cookies.Add(myCookie);
27 }
28
29 protected static bool IsValidDomain(string strIn)
30 {
31 string strPattern = @"^\w+([-.]\w+)*\.\w+([-.]\w+)*$";
32 return System.Text.RegularExpressions.Regex.IsMatch(strIn, strPattern);
33 }
34
业务系统的web.config修改
<!--Cookie名称与根域名需一致-->
<authentication mode="Forms">
<forms name="CookieName" domain=".domain.com" path="/" ></forms>
</authentication>
Moss站点的web.config修改
<!--将MOSS站点web.config中machineKey配置复制到业务系统中,两系统保持一致即可 -->
<machineKey validationKey="C57043728999BCF9537BA55F5978F50722C91B26A0F9D34F"
decryptionKey="C57043728999BCF9537BA55F5978F50722C91B26A0F9D34F"
validation="SHA1" />
<!--Cookie名称与根域名也需一致-->
<authentication mode="Forms">
<forms name="CookieName" domain=".domain.com" path="/" ></forms>
</authentication>
相关文章推荐
- MOSS与业务系统的集成 之 单点登录
- MOSS 2010:Visual Studio 2010开发体验(21)——使用Business Connectivity Service(BCS)集成业务系统
- 公司多业务系统集成sso登录调研
- MOSS 2010:Visual Studio 2010开发体验(21)——使用Business Connectivity Service(BCS)集成业务系统
- MOSS与业务系统的集成 之 自定义Membership实现Forms方式验证
- MOSS与业务系统的集成 之 自定义Membership实现Forms方式验证
- MOSS 2010:Visual Studio 2010开发体验(21)——使用Business Connectivity Service(BCS)集成业务系统
- MOSS 2010:Visual Studio 2010开发体验(21)——使用Business Connectivity Service(BCS)集成业务系统
- jBPM与业务系统集成-通过定制Task Instance等方式实现
- webservice 系统集成(单点登录)
- 如何规划面向业务逻辑的MOSS系统
- 通用权限管理系统组件 中集成多个子系统的单点登录(网站入口方式)附源码
- Liferay 集成 CAS 实现单点登录与应用系统集成
- 云业务系统集成服务
- jBPM与业务系统集成-通过定制Task Instance等方式实现
- 通用权限管理系统组件 (GPM - General Permissions Manager) 中集成多系统的统一登录(数据库源码级)附源码
- ActiveMQ与业务系统的集成
- ActiveMQ与业务系统的集成
- 集成activiti-modeler 到 自己的业务系统