PROTECTing Tables in Visual dBASE 5.x

(Based on an email by Romain Strieff, dBVIPS, in the VdBASE newsgroups)

> Ya..I can easily restrict access from within my program to check the
> security level, and restrictions can be made on a network level, but the
> users are wanting me to go the extra yard to assure that even if someone
> gains access to the file from s outside my program, that they couldn't get
> into the data file to delete or modify records, etc.

If they don't have the masterpassword, nor the supervisor one, that's exactly what will be the result. Not even if they steal the file and take it home. If you want that security whichout login, that's possible as well, see the boilerplate below.

  1. MAKE A BACKUP OF ALL YOUR TABLES, DBTS AND INDEX FILES
  2. Run PROTECT, chose a long complicated password with chrs and number and write it immediately down and store it into a secure place.
  3. Select the [ENFORCEMENT] tab and select WHEN OPENING AN ENCRYPTED TABLE.
  4. Select [USERS] and enter a username, groupname and password
  5. Write them down.
  6. Select [TABLES]
  7. Add all the tables you want to protect
  8. Exit PROTECT.

Now let's assume you entered ROBERT,MAIN,TRUSTNO1 as name, group, password

In the beginning of your program(or QBE or whatever), where you open the first of your PROTECTed tables, use the following code:

cn="ROBERT"
cG="MAIN"
*-- make it more complicated than this so that it will not be visible when *-- _viewing_ the EXEin an Editor
cP="TRUSTNOTONEPERSON"
cP=left(cP,6)+"1"

      If Type("LockWindowUpdate") # "FP"
          extern CLOGICAL LockWindowUpdate(CHANDLE) User
      EndIf
      If Type("GetDeskTopWindow") # "FP"
          extern  CHANDLE   GetDeskTopWindow ( CVOID )  USER
      Endif
      *--this will lock all windows
      LockWindowUpdate(GetDeskTopWindow())  && Freeze
     

      *--put data to type into the login dialog in the keyboard buffer keyboard cn+chr(9)+cg+CHR(9)+Cp+CHR(13)
      *--this will trigger the login screen which will never appear because of
      *--the locked windows and will be filled-in completely automatically
      USE MYTABLE

      LockWindowUpdate(0)  && Unfreeze the form