User Security

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mixed
    New Member
    • Dec 2007
    • 3

    User Security

    Hello everybody!
    I have few querstions.Firs t is how do I password protect cmdbuttons?
    second is..I have a function that have to return true or false, based on priviledges of an user. i have wrotte this function, but I'm not very god at programming and I would like somebodies oppinion.
    here is the function
    Code:
    Option Explicit
    Public UserID As Long
    Public JobPermission As String
    
    Public Function CheckPermission(locUserID As Long, locJobID As Integer) As Boolean
        Dim ipomUser As Integer
        Dim RS As DAO.Recordset
        Dim db As DAO.Database
        Dim strSql As String
        Dim con As New ADODB.Connection
        
        On Error GoTo ErrorMess
        'Set RS = con
        strSql = "SELECT Count(JobID) AS job FROM User as o, PermissionUser AS op where op.UserID=o.UserID and o.UserID=" & locJobID
        Set db = CurrentDb()
        Set RS = db.OpenRecordset(strSql)
        
        'check if there is a permission for user that is log on to application
    
        'RS.Open "SELECT Count(JobID) AS job FROM User as o, PermissionUser AS op where op.UserID=o.UserID and o.UserID=" & locJobID, con, adOpenDynamic, adLockOptimistic
    
        If Not (RS.EOF Or RS.BOF) Then
            RS.MoveFirst
            ipomUser = RS("Job").Value
        Else
            MsgBox "Impossible: CheckPermission."
            Exit Function
        End If
        RS.Close
        
        If ipomUser > 0 Then
            CheckPermission = True
        Else
            CheckPermission = False
        End If
        
    Exit Function
    
    ErrorMess:
        MsgBox "ERROR!"
    
    End Function
    i am trying to do this- i wannt user to log in the system with username and password, but i don't wannt to use access database security, but i would like to use tables of Users and Tables of Priviledges (Permissions). I would like that my application has a logon form (and it does) and based on the name of the user that has logged in i would like to grant him access to certain cmdbuttons, forms, etc. I have user logon form but it doesnt corespond with the rest of the application. everything is opened and i dont wannt that!
    by creating this function i wannted to build in this restrictions, so that i could put some code to every cmdbutton based on username that is loggedon...i would use thi code for cmdbuttons
    Code:
    If Not CheckPermission(UserID, 24) Then
        MsgBox "You don't have permission to do this action."
        Exit Sub
    End If
    help please...i have big problems with access code

    p.s. sorry for my bad english
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32662

    #2
    It's hard to know how to answer this one.
    Your code tells me very little and your English is understandably poor.
    I can't even tell how you're expecting this to work.
    Perhaps some indication of the sort of data you're working with may assist.
    Please post the metadata for your tables [User] & [PermissionUser].

    Here is an example of how to post table MetaData :
    Table Name=tblStudent
    Code:
    [i]Field; Type; IndexInfo[/i]
    StudentID; AutoNumber; PK
    Family; String; FK
    Name; String
    University; String; FK
    Mark; Numeric
    LastAttendance; Date/Time
    Please try to post it correctly as per the example. This is not language based so there would be no good excuse for failing to provide this data correctly. If there is anything about this you don't understand just ask.

    Comment

    Working...