为何已设置Open/Run权限的Access窗体,ADOX GetPermissions返回0?
Access 2003用户级安全中ADOX读取窗体Open/Run权限返回0的问题
场景
- 拥有一个启用用户级安全(User Level Security)的Access 2003(.MDB)数据库
- 数据库内存在组G和窗体F
- 通过“用户与组权限”对话框,为组G仅设置窗体F的Open/Run权限
- 使用属于组G的用户U登录,可正常打开窗体F
- 在VBA中,将ADOX.Catalog变量cat指向当前数据库,预期调用以下代码会返回
adRightExecute(即0x20000000),但实际返回0(最后一个参数是标识窗体的GUID):cat.Groups("G").GetPermissions("F", adPermObjProviderSpecific, "{c49c842e-9dcb-11d1-9f0a-00c04fc2c2e0}")
我翻遍了各种资料,惊讶地发现ADO问世二十年来,居然没人提过这个情况!大概率是我的操作哪里出错了,求各位提供解决思路。
更新1
- 当前权限设置情况:

- 使用的测试函数:
Function GetPermissionsGroupForm(groupName As String, formName As String) As Long Dim cat As ADOX.Catalog Set cat = New ADOX.Catalog Set cat.ActiveConnection = CurrentProject.Connection GetPermissionsGroupForm = _ cat.Groups(groupName).GetPermissions( _ formName, _ adPermObjProviderSpecific, _ "{c49c842e-9dcb-11d1-9f0a-00c04fc2c2e0}") End Function - 调用
GetPermissionsGroupForm("G", "F")始终返回0(ADOX 2.8和6.0版本结果一致)
更新2
供参考,ADOX Permissions(Long型)的结构如下:
| BIT | Value | Meaning |
|---|---|---|
| 00 | 0x00000001 | NOT USED |
| 01 | 0x00000002 | NOT USED |
| 02 | 0x00000004 | NOT USED |
| 03 | 0x00000008 | NOT USED |
| 04 | 0x00000010 | NOT USED |
| 05 | 0x00000020 | NOT USED |
| 06 | 0x00000040 | NOT USED |
| 07 | 0x00000080 | NOT USED |
| 08 | 0x00000100 | adRightDrop |
| 09 | 0x00000200 | adRightExclusive |
| 10 | 0x00000400 | adRightReadDesign |
| 11 | 0x00000800 | adRightWriteDesign |
| 12 | 0x00001000 | adRightWithGrant |
| 13 | 0x00002000 | adRightReference |
| 14 | 0x00004000 | adRightCreate |
| 15 | 0x00008000 | adRightInsert |
| 16 | 0x00010000 | adRightDelete |
| 17 | 0x00020000 | adRightReadPermissions |
| 18 | 0x00040000 | adRightWritePermissions |
| 19 | 0x00080000 | adRightWriteOwner |
| 20 | 0x00100000 | NOT USED |
| 21 | 0x00200000 | NOT USED |
| 22 | 0x00400000 | NOT USED |
| 23 | 0x00800000 | NOT USED |
| 24 | 0x01000000 | NOT USED |
| 25 | 0x02000000 | adRightMaximumAllowed |
| 26 | 0x04000000 | NOT USED |
| 27 | 0x08000000 | NOT USED |
| 28 | 0x10000000 | adRightFull |
| 29 | 0x20000000 | adRightExecute |
| 30 | 0x40000000 | adRightUpdate |
| 31 | 0x80000000 | adRightRead |
我尝试了所有标记为NOT USED的位以及已定义权限的组合,试图通过SetPermissions设置Open/Run权限,但全部失败!
内容的提问来源于Stack Exchange,提问作者Aram Gharib
相关产品推荐
相关产品推荐

