如何创建一个登录表单,提供不同级别的两个用户的访问权限。 [英] How to make a login form that gives access of two user on different levels.

查看:244
本文介绍了如何创建一个登录表单,提供不同级别的两个用户的访问权限。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发vbnet和访问系统。我希望我的系统可以访问具有不同访问级别的2个用户,我希望第一个作为管理员访问它自己的表单,名为LibrarySystemForm作为管理员,第二个是访问其自己的表单的用户,也称为cuulibForm 。

这里我使用的代码给了他们相同的访问权限,我应该怎么做,以获得与管理员不同的第二个用户的另一个访问权限?好的,我希望得到你的建议

我建议有人可以建议我如何改变以下代码。



I'm developing a system in vbnet and access. I would like that my system gives access to 2 user with different levels of access, I would like that the first one as admin that access it own form called LibrarySystemForm as an administrator and the second one a User that access its own form too called cuulibForm.
Here the code I've used give them the to the same access, what should I do, to have another access to the second user that is different to the admin? ok I hope to get your advice
I would suggest someone who may advice me how I can change a bit on this following codes.

Imports System.Data.OleDb

Public Class LoginCuuLibForm
    Dim con As New OleDbConnection

    Private Sub LoginCuuLibForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        con.ConnectionString = "Provider= Microsoft.ACE.OLEDB.12.0;Data Source = CUULibDB.mdb.accdb; persist security info =false"
    End Sub

    Public Function ask()
        Dim dt As New DataTable
        Dim ds As New DataSet
        ds.Tables.Add(dt)
        con.Open()
        Dim da As New OleDbDataAdapter("Select * from login", con)
        da.Fill(dt)

        For Each datarow In dt.Rows

            If txtUsername.Text = datarow.item(1) And txtPassword.Text = datarow(2) And cobSertype.Text = datarow(3) Then
                con.Close()
                Return True


            End If

        Next
        con.Close()
        Return False

    End Function


    Private Sub btnLog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLog.Click
        If ask() = True Then
            LibrarySystemForm.Show()
        Else
            MessageBox.Show("invalid")
        End If

       
    End Sub



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        txtUsername.Clear()
        txtPassword.Clear()
    End Sub
End Class

推荐答案

你可以去 ASP.NET授权 [ ^ ]。 />


否则你可以运用你自己的逻辑,如下所示...





  • 添加一个角色表并将其与登录表相关联。对于每个用户角色表中将有一行。
  • 时注册,您将在角色表中插入行。
  • 登录时,您将从角色表中获取用户角色
  • 根据角色,您将完成工作。
You can go for ASP.NET Authorization[^].

Else you can apply your own logic, something like below...


  • Add one Role Table and relate that to the Login Table. For each User, there will be a row in Role Table.
  • At the time of Registration, you will insert row in Role Table.
  • At the time of Login, you will fetch the Role of User from Role Table.
  • According to the Role, you will then do your work.


这篇关于如何创建一个登录表单,提供不同级别的两个用户的访问权限。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆