C Examples: DbiOpenSecurityList

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

C Examples: DbiOpenSecurityList

Return to chapter overview

Get security information for the specified table.

SecInfo must be allocated large enough to hold security information. This example uses the following input:
         fDbiOpenSecurityList(hDb, "MYSECTBL.DB", Buffer);

DBIResult fDbiOpenSecurityList(hDBIDb hDb, pCHAR TblName, pCHAR SecInfo)

{

   DBIResult      rslt;

   SECDesc                      SecDesc;

   hDBICur                      hTmpCur;

   CHAR           Buffer[200], Priv[20];

   SecInfo[0] = '\0';

   rslt = Chk(DbiOpenSecurityList(hDb, TblName, szPARADOX, &hTmpCur));

   if (rslt == DBIERR_NONE)

   {

      while (DbiGetNextRecord(hTmpCur, dbiNOLOCK, (pBYTE)&SecDesc, NULL) == DBIERR_NONE)

      {

         switch (SecDesc.eprvTable)

         {

            case prvNONE: strcpy(Priv, "None"); break;

            case prvREADONLY: strcpy(Priv, "Read Only"); break;

            case prvMODIFY: strcpy(Priv, "Modify"); break;

            case prvINSERT: strcpy(Priv, "Insert"); break;

            case prvINSDEL: strcpy(Priv, "Insert/Delete"); break;

            case prvFULL: strcpy(Priv, "Full"); break;

            case prvUNKNOWN: strcpy(Priv, "Unknown"); break;

         }

         wsprintf(Buffer, "\r\nID: %d, Privileges: %s, Password: %s",

               SecDesc.iSecNum, Priv, SecDesc.szPassword);

         strcat(SecInfo, Buffer);

      }

   }

   return rslt;

}