The application of dictionary in authority management

Source: Internet
Author: User
Recently helped a friend to do a more successful day-to-day office management projects, all programs with ASP, taking into account the previous permissions control is not very successful, this time to redesign the rights control section, all rights control of the validation role of the relevant functions, The initialization role functions are placed in a page popedom.asp.
Because the user's permissions role is stored in the Database User Rights table, you can perceive the contents of the Permission table: User-> roles, now my solution is to store the user-> roles in dictionary, And as a global variable (the global variable here means page-level, if it's a application-level global variable, it should be better performance, but if too much use can have a negative effect, this will degrade the performance of the Web server).
Here is a description of the actual user and role:
Jane is a member of multiple project groups: Project A, Project B, Project C
John belongs to projects B and C
Emily belongs to project a
==========================
1. Separate the query user role from the role validation:
Through the recordset query, all users and roles are stored in DIC, the corresponding relationship is user-> roles, if you want to verify the role of one or more users, only need to operate DIC, so the benefit of separation is self-evident: to facilitate the readability and maintenance of the code.
2. Avoid multiple inquiries and verification:
Now you want to know if John is a member of Project B, ok! You use the recordset permission table to query John's permissions, and in another place, you want to know if Jane and Emily are members of Project A, and you use the recordset to query the permission table, which is a problem! Who would do that? It is obviously unwise to manipulate the recordset query permissions more than once, to keep all users and roles in DiC, and to query a person's role only if it is obtained from DIC.

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.