The design and implementation of Rights management (including demo and original code)

Source: Internet
Author: User
Tags chr include
The core of design rights Management is to assign resources to manage corresponding permissions for users with different permissions.





This example takes a website column backstage Management module (resources) The Authority management as an example, realizes the different user's authority management.





Database design:





Account Information table:


f_i_autoid automatic encoding (primary key)


F_i_orderid


F_accountid Account Encoding


f_accountname Account (foreign key)


F_password Password


F_accounttype


F_username


F_remark


F_datetime








Column Information table:


f_i_autoid automatic encoding (primary key)


F_i_orderid


f_lanmuid Column Coding


f_lanmuname column (foreign key)


F_ishidden


F_remark


F_datetime








Permission table:


f_i_autoid automatic encoding (primary key)


f_accountname Account (foreign key)


f_lanmuname column (foreign key)


F_remark


F_datetime





The Account information table through the F_accountname account (foreign key) of the permission table and the F_lanmuname column (foreign key)


and the Column information table, by giving the "account" Allocation "column", or to "column" allocation "account", so that the account and columns to establish a relationship (can be "One-to-many" "more than one" or "Many-to-many").





then, based on the current logged on account, finds its manageable columns (resources) in the permission table.





This example realizes a user's management of multiple columns (but a column can only be managed by one user-this is implemented by the constraints of the program code).





The following is part of the code:


<% Option Explicit%>


<!--#include file= "./globals.inc"-->


<!--#include file= "./connects.inc"-->





<html>


<head>


<title> Edit Permissions </title>


<link href= "./style/style.css" rel= "stylesheet" type= "Text/css" >


<meta http-equiv= "Content-type" content= "text/html"; charset=gb2312 ">


<meta http-equiv= "Page-enter" content= "Blendtrans (duration=1.0)" >


<meta http-equiv= "Page-exit" content= "Blendtrans (duration=1.0)" >


<script language= "JavaScript" >


function Openwin (URL, L, T, W, h)


{Open (URL, ', ' toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width= ' + w + ', height= ' + H + ', Left= ' + L + ', top= ' + t);}





function Check_and_submit (frm)


{


SelectAll (frm. SelectedItem);


Frm.submit ();


}


</script>


</head>





<body topmargin=20 leftmargin=0 background= ". /images/bg.gif ">





<%


Dim sSQL, Rs1, Rs2, RS3, Currentaccount





Currentaccount = Request ("Currentaccount")


%>





<form name= "Frm1" id= "Frm1" method= "post" action= "save.asp" >


<input name= "Allowsubmit" type= "hidden" value= "OK" >





<table width= border= "0" cellspacing= "0" cellpadding= "0" align= "center" >


<tr height=30>


<TD colspan=3>





Account information:


<input name= "AccountName" type= "hidden" value= "<%=CurrentAccount%>" >


<%


sSQL = "SELECT * from Tabaccountinfo where F_accountname= '" & Currentaccount & "'"


Set rs1 = Server.CreateObject ("ADODB. Recordset ")


Rs1.open sSQL, sconn, 1, 1


if rs1.eof and Rs1.bof then


Response.Write ("No information was obtained from the user.") ")


Response.End


Else


Response.Write "[Account number:] <font color= #ff0000 >" & Rs1 ("F_accountname") & "</font> [user name:]" & R S1 ("F_username") & "[Account Type:]" & Rs1 ("F_accounttype")


End If


Set rs1 = Nothing


%>


</td>


</tr>


<tr height=10><td colspan=3></td></tr>


<tr>


<TD width= "Align=center" valign= "Top" >


has assigned this user-managed column:<br><br>


<select name= "SelectedItem" id= "SelectedItem" size=12 multiple= "true" >


<%


' Select all columns to remove the assigned columns:


sSQL = "Select F_lanmuname from TABQXB where F_accountname= '" & Currentaccount & "ORDER by F_lanmuname"


Set rs3 = Server.CreateObject ("ADODB. Recordset ")


Rs3.open sSQL, sconn, 1, 1


if rs3.eof and Rs3.bof then


Response.Write ("<option> no </option>") & Chr (13)


Else


While not rs3.eof


Response.Write "<option>" & Rs3 ("F_lanmuname") & "</option>" & Chr (13)


Rs3.movenex







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.