Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Using AllowByPassKey

Posted on 1998-07-31
12
390 Views
Last Modified: 2011-09-20
Access97.  I want to deploy a database and prevent users from using the shift key when opening the database.  The AllowByPasskey property will do this.  But I can't figure out how to do it.  The notes I have state:

The AllowByPasskey Property can only be set from code, and should be set to false.  However, a backdoor to the database can be enabled, by using the /cmd option on a command line. for example:

c:\my documents\msaccess.exe test.mdb /cmd AllowShift

The example above, the command line passes the phrase AllowShift to the Access Command() function.  Add code to the application's startup form to check for the special string (AllowShift) in the Command() function and set the AllowByPasskey property to True if the string is found.  A developer can then reopen the unlocked application while holding down the shift, which will provide access to built in menus etc.

How do I do this??

any ideas.  please provide code etc.
thanks
Billy Boy
0
Comment
Question by:BillyBoy
  • 4
  • 3
  • 2
  • +2
12 Comments
 

Expert Comment

by:coggie
ID: 1957710
Hi Billy Boy,

Try this on start up of your application:-

IF UCase$(Command$) = "ALLOWSHIFT" then
   <allowshift = False>
End If

Regards,

Coggie
0
 
LVL 1

Expert Comment

by:Sekans
ID: 1957711
BillyBoy,
I use this code in VB to dis-allow use of the shift key.  It works for me, if it works for you let me know.

Public Sub TGLLOCK(STATE As String)
On Error GoTo ERRHAND
Dim dbs as Database
Dim NPWD as String
Dim PRP as Property
Set dbs = OpenDatabase("C:\MYDATABASE.MDB", False, False, ";PWD=PASSWORD")
dbs.Properties("ALLOWBYPASSKEY") = FALSE
dbs.Close
End If
ERRHAND:
mess = Left(nname, 12) & " has received the following error: " _
    & Chr(13) & Err.Number & Chr(13) & Err.Description
If Err.Number = 0 Then
    Err.Clear
ElseIf Err.Number = 3031 Then
        Err.Clear
        response = MsgBox("Invalid", 48, "Invalid Password")
    End If
ElseIf Err.Number = 3270 Then
    Set PRP = dbs.CreateProperty("ALLOWBYPASSKEY")
    PRP.Type = dbBoolean
    PRP.Value = FALSE
    dbs.Properties.Append PRP
    Err.Clear
    Resume Next
ElseIf Err.Number = 3343 Then
    response = MsgBox("The database may need to be repaired", 48, "Error")
    End
Else
    MsgBox "An Unexpected Error Has Occurred" & Chr(13) & "Error Number: " & Err.Number _
    & Chr(13) & "Description: " & Err.Description
    Set ACC = Nothing
End If
End Sub

Please let me know if I can help.

Regards,
Sekans
0
 
LVL 1

Expert Comment

by:Sekans
ID: 1957712
If you want, you can leave out all of the error handling code to make it shorter.

Regards,
Sekans
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:BillyBoy
ID: 1957713
Thanks for your answer/comments.  I am sure they work well for you but how do I implement them.  Where do I put the code, and how do I ensure that it runs when the database opens.

I need a bit more detail, ie step by step instructions

0
 
LVL 1

Accepted Solution

by:
rene_moeller earned 200 total points
ID: 1957714
BillyBoy,

to secure the database do teh following:

Add these functions to a module:

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  'prop not found
        Set prp = dbs.CreateProperty(strPropName, _
          varPropType, varPropValue)
        dbs.Properties.Append prp
        Resume Next
    Else
        'unkown error
        ChangeProperty = False
        Resume Change_Bye
    End If
End Function


Function Init() As Integer
Dim R As Integer
  If UCase$(Command) = "ANY_PARAMETER_YOU_SPECIFY" Then
    R = ChangeProperty("AllowBypassKey", dbBoolean, True)
  Else
    R = ChangeProperty("AllowBypassKey", dbBoolean, False)
  End If
End Function

In your AutoExec macro make sure you call the Init() function

The properties will be set when you open the database, but if the property is changed it will not be active until next time the db is opened.

It looks like you have to specify the full programpath on your commandline if you want to use the /cmd parameter...

"c:\office\access.exe" "c:\data\mydatabase.mdb" /cmd "ANY_PARAMETER_YOU_SPECIFY"

Hope this helps


Rene_Moeller
0
 

Author Comment

by:BillyBoy
ID: 1957715
Excellent!  works a treat.

However, but only a small however.  Can I avoid using an autoexec macro.  I set myself a goal of never using macros, and even one is too many.  Can I call init() from my splash form,  called frmSplash.  Original aye!  Perhaps I can call it from the form load or open property.  if not, then I can live with autoexec, but if so, then how do I call the init function from elsewhere.

thanks

0
 

Author Comment

by:BillyBoy
ID: 1957716
Excellent!  works a treat.

However, but only a small however.  Can I avoid using an autoexec macro.  I set myself a goal of never using macros, and even one is too many.  Can I call init() from my splash form,  called frmSplash.  Original aye!  Perhaps I can call it from the form load or open property.  if not, then I can live with autoexec, but if so, then how do I call the init function from elsewhere.

thanks

0
 
LVL 12

Expert Comment

by:Trygve
ID: 1957717
How about just trying it and let us know ?
0
 
LVL 1

Expert Comment

by:rene_moeller
ID: 1957718
In the Startup forms OnCreate just write ....

Dim R as integer
 R = Init()


thats it.
0
 
LVL 1

Expert Comment

by:rene_moeller
ID: 1957719
In the Startup forms OnCreate just write ....

Dim R as integer
 R = Init()


thats it.
0
 

Author Comment

by:BillyBoy
ID: 1957720
Rene, thanks very much for your help.  an excellent answer.
regards



0
 
LVL 12

Expert Comment

by:Trygve
ID: 1957721
This is really interesting. I would like to implement it. But since I am compiling MDE files for my users, I would like to only allow the Command Line "Trojan Horse" for MDB files so that normal user cannot enter. Perhaps an idea ?
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Exporting from Access 2016 to a CSV file 4 47
ADODB problem 20 37
default combobox value 12 18
Is there a way to link Access 2003 app to an xlsx sheet? 6 23
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
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…

856 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