Was how to form the password one could call the 4 form with each different password. example for the administration can only open the form and form alone administration secretary could only summon his secretary form only & to superiors could open formnya all. thanks for attention & assistance

Dani AI

Generated

For : the simplest, maintainable way is to authenticate once and drive access from a central permissions model rather than juggling separate passwords per form. The replies from and point in that direction; the following fills in how to implement it reliably and securely.

Design: keep one user store and a permissions mapping that links roles (or users) to form identifiers. Load the permitted-form list at login into a compact in-memory structure and use one authorization helper to answer "can this user open that form?". Enforce the check inside each form (for example in the Load event) so someone cannot bypass UI hiding by instantiating a form directly.

A minimal VB.NET pattern (authorization helper + per-form check):

' Authorization.vb
Public Class Authorization
    Private ReadOnly perms As Dictionary(Of String, HashSet(Of String))

    Public Sub New(rolePerms As Dictionary(Of String, HashSet(Of String)))
        perms = rolePerms
    End Sub

    Public Function CanOpen(role As String, formName As String) As Boolean
        Dim allowed As HashSet(Of String) = Nothing
        If perms.TryGetValue(role, allowed) Then
            Return allowed.Contains(formName)
        End If
        Return False
    End Function
End Class

' Usage in a form's Load:
If Not auth.CanOpen(currentRole, "AdminForm") Then
    MessageBox.Show("Access denied")
    Me.Close()
End If

Security and maintenance notes: never store plain passwords; use a modern key-derivation algorithm (see the OWASP Password Storage Cheat Sheet). Use parameterized queries, log denied attempts, centralize form identifiers so permission changes are easy, and add session timeouts.

Recommended Answers

All 2 Replies

your question is not clear..
i can't understand what you mean exactly but i try to answer it..

you want to manage forms depend on user rules.
Use File Menu,,you can disable links on file menu depend on their authority..
After login form, show the main form that contain menu..
so, user only access forms of their rules..

If I understand this correctly, you want user privileges in your application?

When adding a user to your database, add a field to state the users "level", Admin can open all, Level2 only some etc.

When logging in, get the user level and then enable/disable menus accordingly.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.