Connect a line-of-business application
An Access line-of-business application with VBA reads master data, posts transactions through procedures, and should work in a way the database can attribute to the person operating it. It should reach only its own objects, not everything the person may do otherwise.
Solution overview
The service knows the person, not the program: a request from the application and one from Excel by the same person look the same to it. So you separate the application through its own alias and a rule for that alias; you pass the person to SQL Server so procedures, triggers, and views know who is acting.
| Means | Effect |
|---|---|
Own alias for the application (fachanwendung) on the same database | This path's rights kept apart from reports and other applications |
| Rule with several entries per alias | Read here, write through procedures there (see scope per alias) |
Persons: Impersonate and an own login per person, or SESSION_CONTEXT(N'wkl.person') | The database knows the acting person |
Checked statements instead of sql | The VBA class's own queries, checked object by object against the rule |
Implementation
- Create the alias (
DataSources) with a name that names the application and, if wanted,Persons: Impersonate; see pass people's identities through to SQL Server. A rule for the application on its objects only:
[ { "Id": "fachanwendung-auftrag", "Databases": [ "fachanwendung" ], "Resources": [ "views", "procedures" ], "Objects": [ "auftrag.*" ], "Verbs": [ "GET", "POST" ], "ReadOnly": false } ]Assign it to the people or their Windows group (
PersonRules,WindowsAccounts).- Link in Access through the ODBC driver with the alias
fachanwendung; on the company PC with the Windows account, from outside with a personal key and a code. - The VBA class's own queries you enable as checked statements, not with the right
sql; see enable custom statements. - Check: In SQL Server,
SUSER_SNAME()(withImpersonate) orSESSION_CONTEXT(N'wkl.person')shows the person;AuditEntriesnames person, alias, and object per request. The service answers an object outsideauftrag.*through this alias with404.
Result: Through its alias, the application reaches only its objects; the database knows for every posting which person triggered it.
Notes
- No identifier of its own for the application. A key always belongs to a person or a service. Another program of the same person using the same alias reaches the same. Where that isn't enough, the database decides: writing only through procedures that check their own rules.
- Service keys are for programs without a person (interfaces, nightly reconciliation); they never switch identity.
- The VBA class and its sign-in are described in “DbGwClient – VBA class for the data service” (in the documentation of the administration app).