Solved

Using AllowByPassKey

Posted on 1998-07-31
12
382 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
Comment Utility
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
Comment Utility
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
Comment Utility
If you want, you can leave out all of the error handling code to make it shorter.

Regards,
Sekans
0
 

Author Comment

by:BillyBoy
Comment Utility
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
Comment Utility
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
Comment Utility
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
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).

 

Author Comment

by:BillyBoy
Comment Utility
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
Comment Utility
How about just trying it and let us know ?
0
 
LVL 1

Expert Comment

by:rene_moeller
Comment Utility
In the Startup forms OnCreate just write ....

Dim R as integer
 R = Init()


thats it.
0
 
LVL 1

Expert Comment

by:rene_moeller
Comment Utility
In the Startup forms OnCreate just write ....

Dim R as integer
 R = Init()


thats it.
0
 

Author Comment

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



0
 
LVL 12

Expert Comment

by:Trygve
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

771 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

10 Experts available now in Live!

Get 1:1 Help Now