FrontMoss and Business System Integration-custom membership implementation forms VerificationIn this article, we have implemented user integration between the two systems. The following is a single sign-on problem between the two systems.
The best way to achieve single sign-on is to use cookie sharing for systems deployed on two different servers. You only need to use the same domain name for the two systems, and the user saves the cookie name of the user's logon ticket, and the cookie encryption and decryption keys are consistent.
- Cookie Writing Method of Business Systems1 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 // if you use a domain name to access the ADC, add Domain Name Information on the 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 modification of the Business System <! -- The cookie name must be consistent with the root domain name -->
<Authentication mode = "forms">
<Forms name = "cookiename" Domain = ".domain.com" Path = "/"> </Forms>
</Authentication>
- Modify the Web. config of the moss website <! -- Copy the machinekey configuration in the moss website Web. config to the business system. Ensure that the two systems are consistent. -->
<Machinekey validationkey = "c57043728999bcf9537ba55f5978f50722c91b26a0f9d34f"
Decryptionkey = "c57043728999bcf9537ba55f5978f50722c91b26a0f9d34f"
Validation = "sha1"/><! -- The cookie name must be consistent with the root domain name. -->
<Authentication mode = "forms">
<Forms name = "cookiename" Domain = ".domain.com" Path = "/"> </Forms>
</Authentication>
Address: http://www.cnblogs.com/CSharp/archive/2008/08/05/1261104.html