PB Multiple User Rights Management Implementation

zhaozj2021-02-17  56

PB Multiple User Rights Management Implementation (Nanjing Auditing College Education Technology Center 210029 Ding Guo Yong) When we implement a general management system in PB, we will encounter such a situation, as a system, can be divided into several subsystems, there are multiple The operator operates it, each operator is different, even in the same subsystem, the operator is different for the operation permission of each menu item, more detailed, different operators for the same window What is the operation permission of a button in a button, then how can I achieve permission control of different users to a button? The author has accumulated some experience in conducting a system development process, and discussed with you. First, how to make a operator to operate the menu item or button of him, we certainly don't have to make different menu items or windows for different users (of course, this is not a way), considering the menu item And the Visible and Enabled attributes of the button, we naturally think that these two properties can complete the above requirements, such as m_1.m_2.visible = false or cb_1.enabled = false menu is not visible, the operator is naturally unable to operate . Secondly, for a multi-user system, we naturally need to use a table to store basic user information, including the username, password of the user login system, if you want to perform grading control, some fields need to be stored related permissions Information, some finished products are doing this, but they use a menu item that needs to be controlled in a field, which is not very good, in case the design of a permission control, this is done Feasibility is not good, in fact, when performing permission control with a menu item or other control, the status is only two, and the True OR FALSE can be used in one binary number 0 or 1, we can put one All items in the subsystem need to perform permission control are combined into a binary string, each four binary numbers are converted to a character (can be "0", "1", "2" ... "A", "B" , "c", "d", "e", "f"), save in the table, so let's count, if there is 64 items in a subsystem need permission control, only one 64 / 4 = 16-bit character types of character types can be represented, and 64 fields are required to be marked separately as in the past.

Ok, the first step is stored, so how does the Visible or Enabled property of each menu item or other control according to the string of such tag permissions? I noticed that there is a tag property in the PB menu item and other controls, and this attribute we generally don't use it, we can use the Tag property to store a number, this number indicates that the control is in the permission control field. That binary is indicated by 0/1 of the access rights of the control, an example, there is a permission control binary string '01001111010 ....', the menu item "Open file" TAG is 7, then the binary The 7th bit "1" in the string labeled the current user's control permission to "Open File". When a user logs in to the system, after password verification, he will control the authority control field of the system. The string read into a global variable, recovering the string to 0, 1 string, and sets the Visible or Enabled attribute according to the corresponding position of the TAG record, for each item that needs to be permissible. Complete management of permissions. Of course, it is to be noted that some control of the authority is not done after entering the system, but is preliminating when the control is called. An example is given below to illustrate the above discussion. There are three menu items and 2 buttons need to control three menu item names are: tag provided m_a.m_h1.m_m1 m_a.m_h1.m_m2m_a.m_h1.m_m3 3 or more menu items are located in two buttons 1-32 In the window, CB_1 in W_1 is set to 4, 5 in W_2, and the TAG set to 4, 5, which requires 5 bits to indicate their access.

The function getbin is used to carry out the conversion of "0", "1" ..., "a" ... "f" to four binary strings. Getbin (STRING S_CH) Returns StringString S_out, S_Tempinteger i_leninteger istring Tempi_len = LEN (S_CH IF i_len = 0 or isnull (S_CH) THEN S_OUT = "0" end if Temp = "" s_temp = "" for i = 1 to i_len temp = MID (S_CH, I, 1) Choose Case Lower (TEMP) CASE A "s_temp =" 1010 "CASE" B "S_TEMP =" 1011 "Case" C "s_temp =" 1100 "Case" D "S_TEMP =" 1101 "Case" e "s_temp =" 1110 "Case" F "S_TEMP =" 1111 "case" 0 "s_temp =" 0000 "case" 1 "s_temp =" 0001 "case" 3 "s_temp =" 0011 "Case" 4 "s_temp =" 0100 "Case" 5 "S_temp =" 0101 "Case" 6 "S_TEMP =" 0110 "Case" 7 "S_TEMP =" 0111 "Case" 8 "S_TEMP =" 1000 "Case" 9 "S_TEMP =" 1001 "Case Else S_TEMP =" 0000 "end chooses_out = s_out s_temps_temp = "" nextreturn s_out define a global variable s_admin permission information used to store the user logs in: String s_tempselect rights into: s_temp where user =: username and password =: userpassword; s_admin = getbin (s_temp) / / s_admin is stored in transforming permission information. Define a permission function check to complete the conversion from 0, 1 to TRUE, FALSE.

转载请注明原文地址:https://www.9cbs.com/read-30498.html

New Post(0)