Integration of moss and business systems-Single Sign-on

Source: Internet
Author: User

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.

  1. Cookie Writing Method of Business Systems

    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 // 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

  2. 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>
  3. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.