Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Secured MS Access DB

Status
Not open for further replies.

smedvid

MIS
May 28, 1999
1,228
US
I am experimenting with locking down an MS Access DB and have successfully locked down a database, but I can not figure out how to allow developers to open the DB if necessary.

Here is code I used to secure DB.. Along with changing options in StartUp. I unChecked all Allow options and Unchecked Access Special Keys. Now, I appear to be locked out.


Private Sub Form_Load()
'call from startup object - Main Menu Form
Call SecureDatabase

DoCmd.ShowToolbar "Menu Bar", acToolbarNo
DoCmd.ShowToolbar "Form View", acToolbarNo
DoCmd.ShowToolbar "Formatting (Form/Report)", acToolbarNo

End Sub



Private Sub SecureDatabase()
Dim dbsCurrent As DAO.Database
Set dbsCurrent = CurrentDb
' set executable properties.
'set TRUE to enable...
ChangeProperty dbsCurrent, "AllowBreakIntoCode", dbBoolean, False
ChangeProperty dbsCurrent, "AllowBuiltinToolbars", dbBoolean, False
' AllowBypassKey commented out until needed.
ChangeProperty dbsCurrent, "AllowBypassKey", dbBoolean, False
ChangeProperty dbsCurrent, "AllowFullMenus", dbBoolean, False
ChangeProperty dbsCurrent, "AllowSpecialKeys", dbBoolean, False
ChangeProperty dbsCurrent, "StartupShowDBWindow", dbBoolean, False
Set dbsCurrent = Nothing



DoCmd.Restore
End Sub

Private Sub ChangeProperty(dbsCurrent As DAO.Database, strPropertyName As String, varPropertyType As Variant, bolPropertyValue As Boolean)
On Error GoTo SubErr
dbsCurrent.Properties(strPropertyName) = bolPropertyValue

SubExit:
Exit Sub

SubErr:
' if property not found, create it
If Err = 3270 Then
Dim prpNew As DAO.Property
Set prpNew = dbsCurrent.CreateProperty(strPropertyName, 1, bolPropertyValue, True)
dbsCurrent.Properties.Append prpNew
Else
MsgBox Err.Description, vbCritical
End If

End Sub




tia,



Steve Medvid
"IT Consultant & Web Master"

Chester County, PA Residents
Please Show Your Support...
 
You need to read the security faq's here.

Remember the following:
Always use a separate .mdw and explicitely remove all permissions from admin and user name and groups, and make your own user with admin rights, and a user with whatever rights you decide.

Use a shortcut--or more securely, build a short VB .exe file that calls the .mdw using the /wrkgrp in the commandline. This will hide even the knowledge of where the .mdb or .mdw exists from any curious would-be hackers.

I have even gone to the extend of renameing the .mdb and .mdw files with .dll extentsions, putting them in system32 so they get lost in the mass of files there, and MSAccess.exe is called via the VB .exe. This way, it will take a bit of work for most users to even find the .mdb or .mdw (now dll's) to begin using hacking tools on them.

My vb.exe uses a Form that mimicks the Access login form, and a KeyDown event opens a separate textbox where an 'admin' password can be entered to call a different commandline which passes the real 'admin' user name/pwd.

Remember, nothing is perfect or totally secure, but there are always measures to make it one notch harder to hack these things.
--Jim
 
If you're disabling the shift key bypass, you'll have to put some back door in there. The way I do it is that there's a button only visible to people in the admins group. Clicking on that re-enable's the shift key, so the next time you open the database the shift key will be enabled. Another button (or the same one, or a toggle, or whatever) re-disables it. Hopefully you've got a copy of the database that hasn't yet run this code!!

---
Jeremy Wallace
METRIX Project Coordinator
Fund for the City of New York
 
shift key disable seems very loose on Access. You can write other access app and set the shift key enable and disable. Is there way to secure this anyway.
 
We had similar situation, so I wrote a VB6 program that would 'enable' the database (you could try using this code from another Access database):

Set db = OpenDatabase(strFilePointer, , False)
db.Properties("StartUpShowDBWindow") = True
db.Properties("AllowFullMenus") = True
db.Properties("AllowBuiltInToolbars") = True
db.Properties("AllowToolbarChanges") = True
db.Properties("StartupShortcutMenuBar") = "(default)"
db.Properties("StartUpMenuBar") = "(default)"
db.Properties("StartUpForm") = "(none)"
Set db = Nothing


35+ years of 'progress' -- can't we all just go wire boards again?
 
That is what I don't want. Is there way to block this. I want to package the application and don't want anybody to be able to open in design view.

Let me know if somebody tried out something for this.
 
Protect design and hide code with an MDE. As jsteph mentioned, you can go the route of a different MDW file that locks down every object.

35+ years of 'progress' -- can't we all just go wire boards again?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top