DATABASE SECURITY

I NEED TO ADD SOME PASSWORD TO A DATABASE TABLE AND CHANGE THE FIELDS RIGHTS USING DELPHI IN CODE, NOT THE DATABASE EXPLORER

 NEED CODE, NOT SOME WEB PAGES LINKS OR BLA BLA
 
        500
VictorZAsked:
Who is Participating?
 
Greg RowlandConnect With a Mentor Software Designer, SysDBA, WebMaster OwnerCommented:
1) Create a security database with a field for each database or form needing protection and a record for each user or workstation.

2) Define field values that reflect the desired level of protection.

3) When the form or application loads find the user or workstation name in the registry.

4) Match the user/workstation name with the values in the security database.

5) Then set access attributes accordingly.

In my application we use values from 1-99 so future categories can be added.
Presently;

0-25 = no access, form access buttons are grayed out.
26-50= Read Only, some fields may not be visible.
51-75= Read and write some fields.
75-90= Full control accept administrative writes.
91-99= The boss/administrator.

When any form "beginning" with the main form is loaded loop through a multi dimensional array containing a list of components that need protection and their cutoff values, set visibility, read only or other properties based on the value in the security table for that user or workstation.

This method negates the need to have the user enter a password after the system is booted.

I have centralized all of the validation code to one unit for easy of maintenance, and provided a form for the Network admin to add or modify users. New users can be added with default settings depending on where they are in the food chain "Levels 1-5".

May sound like a lot of work, the result is tight as a drum and the boss loves it.


0
 
darinwCommented:
Monitoring question.

darinw
Customer Service
0
 
kretzschmarCommented:
also monitoring . . .
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
SuperSyCommented:
Me too.
0
 
EpsylonCommented:
Ok, here we go again   :o)


Don't know how to add password but if your database supports it you can use 'GRANT' and 'REVOKE' to set privileges:


grant <privilege[,privilege,...]>
   on <rel1>[,...<reln>]
   to [public | group <group> | <username>]

privilege is {ALL | SELECT | INSERT | UPDATE | DELETE | RULE }


Example

grant insert
   on mytab
   to public



revoke <privilege[,privilege,...]>
   on <rel1>[,...<reln>]
   from [public | group <group> | <username>]

privilege is {ALL | SELECT | INSERT | UPDATE | DELETE | RULE }


Examples

revoke insert
   on mytab
   from public
0
 
perkleyCommented:
Listening also
0
 
ITugayCommented:
I'm trying to answer.

Hi Victor,
You ask it again? You miss my answer?

This is working sample how to change Paradox password for table using Delphi in code not Database Explorer.

---------------------
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
    Session.AddPassword('OLD_PASSWORD');
    Table1.Close;
    Table1.Exclusive:=true;
    Table1.Open;
    AddMasterPassword(Table1,'NEW_PASSWORD');
end;


The code bellow is from Delphi help.
-----------------
procedure AddMasterPassword(Table: TTable; pswd: string);

const
  RESTRUCTURE_TRUE = WordBool(1);
var
  TblDesc: CRTblDesc;
  hDb: hDBIDb;
begin
  { Make sure that the table is opened and is exclusive }
  if not Table.Active or not Table.Exclusive then
    raise EDatabaseError.Create('Table must be opened in exclusive ' +
      'mode to add passwords');
  { Initialize the table descriptor }
  FillChar(TblDesc, SizeOf(CRTblDesc), #0);
  with TblDesc do begin

    { Place the table name in descriptor }
    StrPCopy(szTblName, Table.TableName);
    { Place the table type in descriptor }
    StrCopy(szTblType, szPARADOX);
    { Master Password, Password }
    StrPCopy(szPassword, pswd);
    { Set bProtected to True }
    bProtected := RESTRUCTURE_TRUE;
  end;
  { Get the database handle from the cursor handle }
  Check(DbiGetObjFromObj(hDBIObj(Table.Handle), objDATABASE, hDBIObj(hDb)));
  { Close the table }
  Table.Close;

  { Add the master password to the Paradox table }
  Check(DbiDoRestructure(hDb, 1, @TblDesc, nil, nil, nil, False));
  { Add the new password to the session }
  Session.AddPassword(pswd);
  { Re-Open the table }
  Table.Open;
end;

-------
Igor

PS: what's wrong? why lot of people monitoring this question?

0
 
flooderCommented:
Monitoring as well.
0
 
mullet_attackCommented:
me too
0
 
EpsylonCommented:
I'm getting cold....
0
 
Greg RowlandSoftware Designer, SysDBA, WebMaster OwnerCommented:
If you get past the Bla Bla Bla and need help with aspects of coding this solution let me know.
0
 
flooderCommented:
Its a lot of work but it looks like a very workable alternative and the advantage is it is db-independant.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.