Solved

Using AllowByPassKey

Posted on 1998-07-31
12
397 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
[X]
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
  • 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

729 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