日期:2014-05-18  浏览次数:20483 次

教学管理系统的角色问题?
想做一个.NET的教学管理系统,分为教师、学生和管理员三种角色,不同的角色登录后进入不同的页面,请问用什么方式对角色进行定义比较好呢?在登录页面用什么对角色进行判断呢?

------解决方案--------------------
权限分配
------解决方案--------------------
角色表和菜单表
------解决方案--------------------
1:在用户的session中加入用户的角色信息,这样你在判断时就可以直接得到了。
2:用户的一些profile信息最好也加载进session,除了一些极占资源的之外。
比如:用户登录成功后跳转到哪个页面,用户的名称,部门====。

------解决方案--------------------
顶 1、2楼都对
------解决方案--------------------
用权限,给不同权限不同操作就可以了~
------解决方案--------------------
login.aspx
Imports System.Web
Imports System.Web.UI.Webcontrols
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Security
Public Class ValidateUser
Inherits System.Web.UI.Page
Protected WithEvents tbUserName As System.Web.UI.WebControls.TextBox
Protected WithEvents tbPwd As System.Web.UI.WebControls.TextBox
Protected WithEvents pn As System.Web.UI.WebControls.Panel
Protected WithEvents tbNewPwd1 As System.Web.UI.WebControls.TextBox
Protected WithEvents tbNewPwd2 As System.Web.UI.WebControls.TextBox
Protected WithEvents cb As System.Web.UI.WebControls.CheckBox
Protected WithEvents btnLogin As System.Web.UI.WebControls.Button
Protected WithEvents btnReset As System.Web.UI.WebControls.Button
Protected WithEvents btnChaPwd As System.Web.UI.WebControls.Button
Protected WithEvents lblMsg As System.Web.UI.WebControls.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
InitializeComponent()

End Sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not ispostback Then
pn.visible = False
End If
End Sub
Private Sub btnLogin_onclick(ByVal Sender As System.Object,ByVal e As System.EventArgs) Handles btnLogin.click
'It is setting cookie expiration
dim intMinutes as integer
if cb.checked then
intMinutes = 30
else
intMinutes = 1
end if

if ValidateUser(Trim(tbUserName.text),Trim(tbPwd.text)) then
if btnChaPwd.Enabled = true then
Dim conn2 As SqlConnection
Dim cmd2 As SqlCommand
' string to use to connect to your local SQL Server.
conn2 = New SqlConnection("Server= ;uid= ;pwd= ;database= ")
conn2.Open()
' Create SqlCommand to select pwd field from the users table given a supplied userName.
dim strcmd2 as string
strcmd2 = "Select UserRoles from BIU_UserRoles Where UserId='" & Ucase(trim(tbUserName.text)) & "'"
cmd2 = New SqlCommand(strcmd2, conn2)
Dim dr As SqlDataReader
dr = cmd2.ExecuteReader()
if dr.read() then
'创建一个新的验证票FormsAuthenticationTicket
'cookie版本、名、过期日期、发布日期、持久性以及用户定义的数据
Dim ticket As New FormsAuthenticationTicket( _
1, _
Ucase(trim(tbUserName.text)), _
System.DateTime.Now, _
System.DateTime.Now.AddDays(intMinutes), _
false, _
dr.GetString(0)) '指定从dr的第0列取出字符串的值
'用户数据:可用 ((System.Web.Security.FormsIdentity)User.Identity).Ticket.UserData 获取
'把验证票加密
Dim encTicket As String = FormsAuthentication.Encrypt(ticket)
'声明一个 Cookie,名称为 Web.config 中 <forms name=".APSX" … /> 的 name 属性,对应的值为身份验票加密后的字串