Basics
Build time requirement.
To embed the server or client into your projects you need to link to ‘SQLiteQueryAS.dll’, and get the interfaces to the desired functionality. To help you with that and link to it dynamically you can use <LoadPlugin.h>. The interface declarations are in <ISQLQueryAS.h>.
Run-time requirement.
During the run-time the security database has to exist, If the database is missing the client will not be able to open any databases. See below for the security database details.
Security DB helper interface.
There is a helper interface that helps you deal with the security database. Also included in this page is an example which demonstrates the majority of the functions the interface has. examples
Security Database
The server requires one file to exist in order to control user access rights. That is, it requires the "security database" which you set the path to using the following interface.
ISQLiteServer::SetSecurityDatabase()
The security database has to contain one table called db_list. This table contains the list of databases which the server can access. If the client requests a database that is not on this list, the client is denied access.
CREATE TABLE db_list (
id INTEGER PRIMARY KEY AUTOINCREMENT
NOT NULL
UNIQUE,
db_name TEXT NOT NULL
UNIQUE,
db_path TEXT NOT NULL,
db_users_table VARCHAR( 100 )
);
The db_name field contains the name of the database. This field has to match to the filename of the database without the .db extension.
The db_path field contains the path to the folder containing the database.
The db_users_table field contains the table name which contains the users which have access to the database.
Example
db_name = 'myDatabase'
db_path = 'C:\databases\'
db_users_table = 'tbl_1'
The above will be translated by the server into:
C:\databases\myDatabase.db
and tbl_1 will be checked for the username, password and access flags.
The users table has the following format.
CREATE TABLE tbl_1 (
id INTEGER PRIMARY KEY
NOT NULL
UNIQUE,
username VARCHAR( 100 ) NOT NULL
UNIQUE,
password VARCHAR( 100 ) NOT NULL,
permission INTEGER
);
It is important to mention that tbl_1 can be any name. But that name has to match db_list.db_users_table field.
The username field contains the username case sensitive.
The password field contains the password case sensitive.
The permission field contains the access rights the user has to the database.
The permission field is or'ed with the below values.
typedef struct _tag_security_permission
{
static const DWORD GRANT_CREATE_TBALE = 0x00000001;
static const DWORD GRANT_CREATE_VIEW = 0x00000002;
static const DWORD GRANT_CREATE_TRIGGER = 0x00000004;
static const DWORD GRANT_CREATE_ALL =
GRANT_CREATE_TBALE|GRANT_CREATE_VIEW|GRANT_CREATE_TRIGGER;
static const DWORD GRANT_DROP_TABLE = 0x00000008;
static const DWORD GRANT_DROP_VIEW = 0x00000010;
static const DWORD GRANT_DROP_TRIGGER = 0x00000020;
static const DWORD GRANT_DROP_ALL =
GRANT_DROP_TABLE|GRANT_DROP_VIEW|GRANT_DROP_TRIGGER;
static const DWORD GRANT_OP_SELECT = 0x00000040;
static const DWORD GRANT_OP_INSERT = 0x00000080;
static const DWORD GRANT_OP_UPDATE = 0x00000100;
static const DWORD GRANT_OP_DELETE = 0x00000200;
static const DWORD GRANT_OP_ALTER = 0x00000400;
static const DWORD GRANT_OP_ALL =
GRANT_OP_SELECT|GRANT_OP_INSERT|GRANT_OP_UPDATE|GRANT_OP_DELETE|GRANT_OP_ALTER;
static const DWORD GRANT_PRAGMAS = 0x00000800;
static const DWORD GRANT_CREATE_DB = 0x00001000;
static const DWORD GRANT_DROP_DB = 0x00002000;
static const DWORD GRANT_EVERYTHING =
GRANT_CREATE_ALL|GRANT_DROP_ALL|GRANT_OP_ALL|GRANT_PRAGMAS|GRANT_CREATE_DB|GRANT_DROP_DB;
}secur_permission;
GRANT_EVERYTHING = 16383 or 0x00003FFF