Solved

Prevent shift-enter

Posted on 2001-06-19
5
621 Views
Last Modified: 2008-02-26
Hello experts,
I'm looking for an opportunity to prevent any unauthorized user from using shift-enter to gain access to my access-db. You can call that 'private security'.
I do NOT want to create an mde or mde (if there is a way around).
In generally I think there could be a way in modifying
the functionality offered by menu Extras-Start.
But I'm not sure.
There should be also a way for me to have the required menu Extras.
It would be very helpful if I could get a code-snippet to realize that.
Is there a way?
Thank you for any help
  HStrix
0
Comment
Question by:HStrix
5 Comments
 
LVL 8

Accepted Solution

by:
dovholuk earned 200 total points
ID: 6206706
without creating an MDE, there is absolutely NO way to prevent a malicious user from "importing" all of your objects from the "locked" db to a new db.

for that reason alone, you should consider using an MDE.

on top of that, if you store you data in access tables, there is also no way to prevent people from linking to your tables from another .mdb file and modifying data etc.

that being said, here's the function i use:

Public Function SetAllowBypassKey(bBypass As Boolean)

    Dim dbs As Database, prp As Property
    Const conPropNotFoundError = 3270
    Const strKey = "AllowBypassKey"
    Set dbs = CurrentDb
    On Error GoTo SetAllowBypassKeyErr
    If bBypass = False Then
      dbs.Properties(strKey) = False
    Else
      dbs.Properties(strKey) = True
    End If

If bBypass = True Then
   MsgBox "Enabled"
Else
   MsgBox "Disabled"
End If

SetAllowBypassKeyExit:
      Exit Function

SetAllowBypassKeyErr:
      If Err = conPropNotFoundError Then
    ' Property doesn't exist yet
    If bBypass = False Then
    ' Create the property
         Set prp = dbs.CreateProperty(strKey, dbBoolean, False)
      Else
         Set prp = dbs.CreateProperty(strKey, dbBoolean, True)
      End If
      dbs.Properties.Append prp
    ' Add it to the collection
      Resume SetAllowBypassKeyExit
    End If

End Function

call it from whereever (usually the debug window). the one argument is wether you want to enable (true) or disable (false) the shift-bypass key.

another note. i create a macro that calls this function when i need it. usually ctrl-shift-F5 (disable) / ctrl-shift-F6 (enable). the wierd key stroke combination usually ensures that no user can guess the correct keystrokes to enable the bypass key.

also be warned, that macros are NOT secure even when in a .mde file. so a truly smart user can import the autokeys macro, and figue it out that way...

good luck

dovholuk
0
 
LVL 2

Expert Comment

by:englishman
ID: 6206866
I use similar code to disable shift-bypass entry to my db of tables and I also set users and group permissions to zero. - Only having "owner access" makes reading these tables possible. This requires being part of the workgroup and knowing the password.
0
 
LVL 8

Expert Comment

by:dovholuk
ID: 6206945
englishman,

very true. however there are a multitude of access security crackers out there as well... lol.

if security is a major issue, access as a front-end is only "so good".  but as we all know, nothing is ever totally safe.

good comment though...


dovholuk
0
 
LVL 2

Expert Comment

by:WonHop
ID: 6207103
Hello scorp8.  This is the one that I use

Function CheckDisableShiftKey()
Dim strCmdLineText As String
  strCmdLineText = Command()
 ' Set roger = myset![ok]
  If strCmdLineText = "AllowBypassKey" Then
     ChangeProperty "AllowBypassKey", dbBoolean, True
     MsgBox "The application is now unlocked@" & _
        "The application quit now. You will now be able to open the database while holding down the
shift key.@" & _
        "To lock the application again open the database without the special command line parameter
found in this shortcut.", _
        vbOKOnly, "WARNING"
        DoCmd.Quit
  Else
     ChangeProperty "AllowBypassKey", dbBoolean, False
     DoCmd.ShowToolbar "Menu Bar", acToolbarNo
     
  End If
End Function
Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
  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

Put this in the Target of a shortcut
"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" "C:\Joni_Myer\Databases\Joni_Myer_051201.mdb"
/cmd "AllowByPassKey"

It is the path to the Access.exe and the path to your database.  

The /cmd "AllowByPassKey is your password to let you in the database.  
The password in the code is located:
If strCmdLineText = "AllowBypassKey" Then

You can change that to whatever you like.

The way the code works that I provided is you can only open the database by using the ShiftKey only
thru the shortcut.  The cmd line in the shortcut is the password that lets you in.  You will first get
a message that says it is now unlocked then it will close.  Then you can use the ShiftKey to open it.
  When you close the database, open it again without the shortcut with the password in it.  This will
lock it again.

WonHop
0
 

Author Comment

by:HStrix
ID: 6207393
Hello dovholuk,
I've incorporated your code and it worked GREAT!

Thank you very much
 
   HStrix

In addition I thank the other experts as well.
But only one can get the points.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now