vba 有没有办法在 ms-access 数据库中对用户进行身份验证?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/272003/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 10:02:26  来源:igfitidea点击:

Is there any way to authenticate user in a ms-access database?

vbams-accessauthenticationaccess-vbams-office

提问by Varun Mahajan

I have a MS-access database. But it is on the shared drive. And it is required that only some selected number of people can use it. Is there a way to authenticate the user?

我有一个 MS-access 数据库。但它在共享驱动器上。并且要求只有选定的一些人可以使用它。有没有办法对用户进行身份验证?

回答by Patrick Cuff

Yes, open the database then run the Tools->Security->User-Level Security Wizard. It will step you through the process of creating a new workgroup file, creating users and groups, and securing the Access objects.

是的,打开数据库然后运行工具->安全->用户级安全向导。它将引导您完成创建新工作组文件、创建用户和组以及保护 Access 对象的过程。

回答by Knox

Since Access is file driven, why not create a folder in the shared drive and assign folder permissions to the appropriate people.

由于 Access 是文件驱动的,为什么不在共享驱动器中创建一个文件夹并将文件夹权限分配给适当的人。

回答by BIBD

Do both.Set access permissions on the directory AND create a new security file for it.

两者都做。设置目录的访问权限并为其创建新的安全文件。

The directory is your front-line security, and limits access on a macro level

目录是您的前线安全,并在宏观层面限制访问

The security file can be used to segment access to the various tables, forms, reports, etc. You can even us it give some people read only access and others more full permissions.

安全文件可用于对各种表、表单、报表等的访问进行分段。您甚至可以使用它为某些人提供只读访问权限,而其他人则提供更多完整权限。

回答by Mike

I do all of this in VBA. In the switchboard Form_Open sub, Read the user name into a string variable with a windows API, then check to see if the user name in on your list of valid users. If OK, issue a welcome message, if not OK exit Access.

我在 VBA 中完成所有这些。在交换机 Form_Open 子中,使用 Windows API 将用户名读入字符串变量,然后检查用户名是否在您的有效用户列表中。如果正常,则发出欢迎消息,如果不正常,则退出 Access。

' check user Dim user As String Dim AuthorizedUser As Boolean user = UCase(CurrentUser())

' 检查用户 Dim user As String Dim AuthorizedUser As Boolean user = UCase(CurrentUser())

AuthorizedUser = True
Select Case user
    Case "USER_A":
    Case "USER_B":
    Case "USER_C":     
    Case Else: AuthorizedUser = False
End Select

If AuthorizedUser = True Then
   MsgBox "Welcome authorized user " & user
Else
   MsgBox user & "is not Authorized. For access to this database contact User_A"
   DoCmd.Quit
End If

回答by osp70

If you are on a domain could you not use file level security to prevent users from accessing it?

如果您在域中,是否可以不使用文件级安全来阻止用户访问它?

回答by Fionnuala

User-level security is not available in Access 2007.

Access 2007 中不提供用户级安全性。

Get started with Access 2007 securityoffers:

开始使用 Access 2007 安全产品

  • Trust (enable) the disabled content in a database
  • Use a password to encrypt or decrypt a database
  • Package, sign, and deploy an Office Access 2007 database
  • 信任(启用)数据库中禁用的内容
  • 使用密码加密或解密数据库
  • 打包、签名和部署 Office Access 2007 数据库

回答by jeremyasnyder

Two solutions:

两种解决方案:

  1. Place the Access file on a file share with permissions set appropriately. This doesn't work really well if you need to provide read-only access since Access can't write out the temporary .ldb file that it creates when opening an Access file (.mdb).

  2. Move the "data" of the Access file to a Sql Server instance... where you can permissions in SQL server to restrict what people can do. We use this method to provide readonly access to the everyone, and then specific people with read-write access. To move the data to SQL you would import it into a new SQL database and then link the tables into the Access file (renaming so that reports/queries/etc continue to work).

  1. 将 Access 文件放在具有适当权限设置的文件共享上。如果您需要提供只读访问权限,这不会很好地工作,因为 Access 无法写出它在打开 Access 文件 (.mdb) 时创建的临时 .ldb 文件。

  2. 将 Access 文件的“数据”移动到 Sql Server 实例...在那里您可以在 SQL Server 中获得权限以限制人们可以做什么。我们使用这种方法为所有人提供只读访问权限,然后为特定人员提供读写访问权限。要将数据移动到 SQL,您需要将其导入新的 SQL 数据库,然后将表链接到 Access 文件(重命名以便报告/查询/等继续工作)。