当前位置:七道奇文章资讯数据防范Access防范
日期:2011-05-01 23:30:00  来源:本站整理

设置只有管理员才能改变AllowBypassKey属性[Access防范]

赞助商链接



  本文“设置只有管理员才能改变AllowBypassKey属性[Access防范]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
tmtony翻译:

在Access的帮忙文件中阐明CreateProperty 办法的语法:

Set property = object.CreateProperty (name, type, value, DDL)
其实最后一个参数是这个注释的(部份描写):

DDL 可选. 一个变量(逻辑子范例) 指定这个属性能否为DDL对象. 贫乏值为False. 假如设置为TRUE,除非他有 dbSecWriteDef 权限,用户就不能改变或删除这个属性
CreateProperty 是用来成立或设置 AllowBypassKey 属性假如这个属性设为TRUE, 那便可以禁用户近SHIFT键来禁止启动属性和AutoExec 宏. 但是,ACCESS帮忙中供应的例子没有利用第四个 DDL 参数. 这意味着任何人都可以翻开数据据然后用程序复位AllowBypassKey 属性.

所以,为了限制普通用户去改变这个属性,所以我们设置第四个参数为TRUE .

为了比较,我们也同时列出了ACCESS本身的例子以便参照

' *********** Code Start ***********
Function ChangePropertyDdl(stPropName As String, _
PropType As DAO.DataTypeEnum, vPropVal As Variant) _
As Boolean
' Uses the DDL argument to create a property
' that only Admins can change.
'
' Current CreateProperty listing in Access help
' is flawed in that anyone who can open the db
' can reset properties, such as AllowBypassKey
'
On Error GoTo ChangePropertyDdl_Err

Dim db As DAO.Database
Dim prp As DAO.Property

Const conPropNotFoundError = 3270

Set db = CurrentDb
' Assuming the current property was created without
' using the DDL argument. Delete it so we can
' recreate it properly
db.Properties.Delete stPropName
Set prp = db.CreateProperty(stPropName, _
PropType, vPropVal, True)
db.Properties.Append prp

' If we made it this far, it worked!
ChangePropertyDdl = True

ChangePropertyDdl_Exit:
Set prp = Nothing
Set db = Nothing
Exit Function

ChangePropertyDdl_Err:
If Err.Number = conPropNotFoundError Then
' We can ignore when the prop does not exist
Resume Next
End If
Resume ChangePropertyDdl_Exit
End Function

帮忙本身的例子
Function ChangeProperty(strPropName As String, _
varPropType As Variant, varPropValue As Variant) As Integer
' The current listing in Access help file which will
' let anyone who can open the db delete/reset any
' property created by using this function, since
' the call to CraeteProperty doesn't use the DDL
' argument
'
Dim dbs As Database, prp As Property
Const conPropNotFoundError = 3270

Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName) = varPropValue
ChangeProperty = True

Change_Bye:
Exit Function

Change_Err:
If Err = conPropNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strPropName, _
varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
' Unknown error.
ChangeProperty = False
Resume Change_Bye
End If
End Function
' *********** Code End ***********   以上是“设置只有管理员才能改变AllowBypassKey属性[Access防范]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
  • 设置只有管理员才能改变AllowBypassKey属性
  • 本文地址: 与您的QQ/BBS好友分享!
    • 好的评价 如果您觉得此文章好,就请您
        0%(0)
    • 差的评价 如果您觉得此文章差,就请您
        0%(0)

    文章评论评论内容只代表网友观点,与本站立场无关!

       评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论
    Copyright © 2020-2022 www.xiamiku.com. All Rights Reserved .