Secure programming of Access database

Almost everyone who uses a Microsoft Access application uses one of the (or all) of the following ways to protect the database (database), to lock their hands and lock the curious employees:

1. Protect the VBA (Visual Basic for Application) code by selecting the Properties on the Tools menu of the Microsoft Visual Basic editor window and selecting the Protection page on the Project Properties dialog box. Finally, select Lock project for viewing , along with a password protection. In this way, the structure and data of tables can still be viewed and modified.

2. Use the Make MDE file function to prevent modification of code, form design and report design. In this way, the structure and data of tables can still be taken to transfer to another .MDB file that is viewed and modified.

3. Use Encrypt / Decrypt database . to encrypt the database, prevent utility programs from processing decrypted documents, but still use Access to open.

4. Use the Set database password function to specify the password for the database. This is a little annoying if there is a table in another database that links (links) to it. If I forgot my password . would I cry?

5. Design a boot form, which requires a name and password, using the Startup dialog box (from the Display Form / Page list ) to specify this form to be opened each time you first open the database. This way, you can hide the Database window, where you can view and select the components of the database to repair.

In the above ways, the 5th way can still be overcome by pressing and holding the Shift key while opening the database. To fix this, we can use Visual Basic to assign False to the AllowBypassKey property to disable the Shift key when opening the database.

Suppose you have a database named dbLock.MDB. Every time people open it, you want the frmKhoiDong form to always be displayed first by specifying Display Form / Page as frmKhoiDong . To change the AllowBypassKey property , it is required to open the database, assign a new value to this attribute, close the database, then open the new database. Remember, it is necessary to lock it so that people cannot open it and open it, which means we must have the key to open it. The key here is another form, such as frmChiaKhoa .

Once you have changed the AllowBypassKey property , make sure the frmKhoiDong form is displayed when you open the database. So we put the key through this form by drawing a control box (as long as it has a procedure to handle the Click situation is okay), such as label lblChiaKhoa , then set the Visible property to No and add command line DoCmd.OpenForm 'frmChiaKhoa' into the procedure to handle the situation Click . You have to remember the location of the label to get the key out. Thus, the remaining problem is in the frmChiaKoa form.

Open the Microsoft Visual Basic editor window, select References . to ensure Microsoft DAO xx.xx Object Library (where xx.xx version may be: 2.5 or 3.51 or 3.6 depending on Access version, of course should choose the latest version) selected in the Available References list.

Secure programming of Access database Picture 1

Figure 1 : Design form

Figure 1 is a frmivided form. The tree needs to be designed, including a text box txtPassword to receive the password that the person who needs to unlock must type, a cmdLock button performs the database lock and a cmdUnlock button to perform database unlock . Done, you type the procedures to process as code 1. Before messing up this on a database, you should copy the database to prevent the lock problem but cannot open it (because you mistakenly type the command line) .

Code snippet 1

'The ChangeProperty function changes the properties of the database

Function ChangeProperty (strPropName, varPropType, varPropValue)

Dim dbs As Database, prp As Property

Const conPropNotFoundError = 3270

Set dbs = CurrentDb

On Error GoTo Change_XuLyLoi

dbs.Properties (strPropName) = varPropValue

ChangeProperty = True

Change_KetThuc:

Exit Function

Change_Language:

'Attribute not found

If Err = conPropNotFoundError Then

Set prp = dbs.CreateProperty (strPropName, _

varPropType, varPropValue)

dbs.Properties.Append prp

Next Resume

Else

'I don't know what the error is

ChangeProperty = False

Resume Change_KetThuc

End If

End Function

'Handling the situation of selecting the [Lock database] button

Private Sub cmdLock_Click ()

'This form is preloaded

ChangeProperty "StartupForm", dbText, "frmKhoiDong"

ChangeProperty "StartupShowDBWindow", dbBoolean, False

ChangeProperty "StartupShowStatusBar", dbBoolean, False

ChangeProperty "AllowBuiltinToolbars", dbBoolean, False

ChangeProperty "AllowFullMenus", dbBoolean, False

ChangeProperty "AllowBreakIntoCode", dbBoolean, False

ChangeProperty "AllowSpecialKeys", dbBoolean, False

 

'Do not use the Shift key to skip the form frmKhoiDong

ChangeProperty "AllowBypassKey", dbBoolean, False

 

MsgBox "Database has been locked! Close the database, _

then reopen it to press-es. ", vbOKOnly," eChip Security "

cmdExit.SetFocus

cmdUnlock.Visible = True

cmdLock.Visible = False

End Sub

'Handling the situation to select the button [Open database]

Private Sub cmdUnlock_Click ()

'No boot form needed

ChangeProperty "StartupForm", dbText, ""

ChangeProperty "StartupShowDBWindow", dbBoolean, True

ChangeProperty "StartupShowStatusBar", dbBoolean, True

ChangeProperty "AllowBuiltinToolbars", dbBoolean, True

ChangeProperty "AllowFullMenus", dbBoolean, True

ChangeProperty "AllowBreakIntoCode", dbBoolean, True

ChangeProperty "AllowSpecialKeys", dbBoolean, True

ChangeProperty "AllowBypassKey", dbBoolean, True

MsgBox "The database has been unlocked! _

Close the database, then reopen it with press-approval. ", _

vbOKOnly, "eChip Security"

cmdExit.SetFocus

txtPassword = ""

cmdLock.Visible = True

cmdUnlock.Visible = False

txtPassword.Visible = False

End Sub

'Handle the situation when opening the form

Private Sub Form_Open (Cancel As Integer)

Dim dbs As Database

Set dbs = CurrentDb

On Error GoTo KhongCoThuocTinh_Err

If dbs.Properties ("AllowBypassKey") Then

cmdLock.Visible = True

txtPassword.Visible = False

Else

cmdLock.Visible = False

txtPassword.Visible = True

End If

Sub Exit

KhongCoThuocTinh_Err:

cmdLock.Visible = True

txtPassword.Visible = False

End Sub

'When people type the password and press the Enter key

Private Sub txtPassword_LostFocus ()

If txtPassword = "echip" Then

cmdUnlock.Visible = True

End If

End Sub

3.5 ★ | 2 Vote

May be interested

  • MS Access 2007 - Lesson 1: Get started with Microsoft Access 2007MS Access 2007 - Lesson 1: Get started with Microsoft Access 2007
    the microsoft office button (the yellow circle icon in the upper left corner) performs many functions that are located in the file menu in older access versions. this button allows you to create a new database (new), open an existing database (open), save (save) and save as (save as), print (print), send or close.
  • How to Hack a DatabaseHow to Hack a Database
    the best way to make sure your database is secure from hackers is to think like a hacker. if you were a hacker, what sort of information would you be looking for? how would you try to get it? there are numerous types of databases and many...
  • How to implement role-based access control in Express.js REST API using Passport.js and JWTHow to implement role-based access control in Express.js REST API using Passport.js and JWT
    role-based access control is a secure authentication mechanism. you can use it to restrict access to certain resources.
  • How to Hack a DatabaseHow to Hack a Database
    the best way to make sure your database is safe from hackers is to think like a hacker. if you were a hacker, what kind of information would you look for? what will you do to get that information? there are many diverse methods to hack different types of databases, but most hackers will try to crack high-level passwords or execute database attacks. if you are familiar with sql commands and understand basic programming languages, you can try hacking a database.
  • Database security (common usage guidelines)Database security (common usage guidelines)
    recently, the database security issue has spread widely on the mass media and internet news network. the first is the slammer worm and most recently the illegal access to more than 8 million credit card numbers. many people put
  • eQuiz - Multiple choice test on ASPeQuiz - Multiple choice test on ASP
    here is a small test of asp web programming language, a total of 30 questions will be answered with no time to answer each sentence.
  • Access the database via C # ADO.NETAccess the database via C # ADO.NET
    in this article, i will show you how to access the database via c # ado.net.
  • Secure Outlook Web Access using SSLSecure Outlook Web Access using SSL
    outlook web access (owa) has become a very important component of exchange. many companies deploy owa to allow users the ability to access email almost anywhere. the content in this article is how to deploy owa to make it more secure with secure socket
  • MS Access 2003 - Lesson 6: Creating a table in AccessMS Access 2003 - Lesson 6: Creating a table in Access
    after creating the database, you need to create at least one table. access uses tables to determine the data structure in the database. each table contains a collection of related information.
  • eQuiz - Multiple choice test on SQLeQuiz - Multiple choice test on SQL
    this is a small test of the sql database administration system, there will be 10 questions in total with no time for answering each sentence.