Integration solution of cnforums and existing systems

Source: Internet
Author: User
Maybe we already have a complete system and a user system, and we need to add a forum, that is, integrate with cnforums, to share verification and user information. There may be many solutions. Taking a set of solutions I have previously written as an example, I would like to explain my ideas and specific implementation processes:

First, let's talk about user sharing. The best practice is to share a user library, which is generally not convenient. Therefore, the simplest and most effective way is to ensure synchronization between the two user libraries, that is to say, the user table data of the previous system has a copy of the table data in cnforums. The registration/modification data of all systems/logon are at the same portal, and the modification data is modified synchronously, registered users are synchronized. Note that there are two data tables in cnforums: forums_users and forums_userprofile, which are associated with userid. When synchronizing user data, it is best to directly use the existing registration/modification Stored Procedure forums_user_createupdatedelete of cnforums, or refer to its implementation. (Note: If you want to synchronize the password, pay attention to the @ passwordformat parameter. If the previous system password is not encrypted, the value of this parameter is set to 0, otherwise, set a number after 10)
The specific implementation is to install all the tables and stored procedures of cnforums on the original database, because all stored procedures and tables of cnforums are started with forums _, so it is easy to distinguish. Use SQL to call the cnforums forums_user_createupdatedelete stored procedure or refer to its implementation to write an SQL statement or importProgramImport the user data of the previous system to the cnforums User table, modify the data and register the program, and ensure the synchronization of user data between the two regions.

After the user synchronizes, it means shared login verification. There are two methods for shared login verification, one is to ensure password synchronization, and the other is to use only one system login verification.
Let's talk about the first one. cnforums can support multiple password verification schemes. If your previous password is not encrypted, you don't need to change anything, note that when synchronizing users, the passwordformat field of user data is 0. If you use your own encryption method, you need to modify the source code of cnforums, in aspnetforums. enumerations. add enumeration in userpasswordformat. The enumerated value is the same as the value of the @ passwordformat parameter when synchronizing user data. That is why you set a number greater than 10. Add your original system encryption in the aspnetforums. Users. Public static string encrypt (userpasswordformat format, string cleanstring, string salt) method. Algorithm .
If the first type is too complex, you can use the second type to share a logon verification. cnforums uses the forms authentication of Asp.net. When Logon is successfully authorized, log on to the username (for details, see aspnetforums. login. CS: formsauthentication. setauthcookie (usertologin. username, autologin. checked). In the future, the user information will be retrieved Based on the Login User Name (For details, refer to aspnetforums. users. getuser (), aspnetforums. users. getloggedonusername () and aspnetforums. forumshttpmodule. application_authenticaterequest (Object source, eventargs e) method, forumconte XT. current. username = context. user. identity. name;), so if we want cnforums to share the logon verification of the master system, we can record the username, that is, login, after successfully logging on to the master system. formsauthentication in CS. setauthcookie (usertologin. username, autologin. checked). In cnforums, as long as the user currently logged on exists in the table, the current user will be considered as logged on (in the httpmodule of cnforums, if the currently logged-on username is not recorded in the table, it will be automatically logged out, so be sure to keep the user table synchronized ). Note that forms authentication cannot be cross-origin. Therefore, you need to install cnforums without a virtual directory. You can search previous posts for specific methods.
The specific implementation of the second solution:
Install cnforums without a virtual directory;
In the logon program of the primary system, after the password is verified successfully, use formsauthentication. setauthcookie (username, autologin) to set the logon success. In this way, after the primary system is logged on, cnforums is also successfully logged on.

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.