How to implement user-level security in Access 2007

后端 未结 3 975
说谎
说谎 2020-12-11 11:25

So after some digging I realize that there is no built in user level security option for Access 2007. What I need to do is restrict records that users can edit based on who

3条回答
  •  情歌与酒
    2020-12-11 12:15

    Assigning username/passwords in Access (especially with an access back end) has a number of critical issues that are worth pointing out. Firstly, if you don't encrypt your DB, then any of your users who are savvy enough to go looking for it will be able to find it, and therefore get full access to it. If you encrypt the DB, if anyone can get access to your source code you're toast, since they will be able to see the DB user/passwords stored in the code. This issue persists if you use other SQL db's, but at least in those cases you can restrict the user supplied to the Access .accdb file to have certain permissions.

    For my case, I have 3 levels of security. Firstly, I heavily restrict what I send out to make it very difficult to access the source code, which you kind of have to do no matter what. Secondly, I distribute different levels of access with different DB passwords (I'm using a MySQL back-end, you could do the same with a SQLServer back-end, but with Jet you're out of luck), so even if users could see the DB user and password, they are limited in what they can do. Thirdly, since I deploy on a corporate network, I take advantage of windows groups, and use those to filter out what is visible to different users. That way, users can only use the forms if they are authenticated onto our network. If the file discovers it's not on the network, it deletes itself and terminates.

    Function IsMember(strDomain As String, strGroup _
    As String, strMember As String) As Boolean
        Dim grp As Object
        Dim strpath As String
    
        strpath = "WinNT://" & strDomain & "/"
        Set grp = GetObject(strpath & strGroup & ",group")
        IsMember = grp.IsMember(strpath & strMember)
    End Function
    
    Function GetCurrentUser() As String
        GetCurrentUser = VBA.Environ$("USERNAME")
    End Function
    
    Function GetCurrentDomain() As String
        GetCurrentDomain = VBA.Environ$("USERDOMAIN")
    End Function  
    

提交回复
热议问题