Database

All the objects needed for RLS functionality are created in a predefined order:
SQL Command:
Exec [dbo].[pPA_RLSCreate]
For faster queries, data from t%usersecurity tables is joined with register data and users who have the permissions to access certain data are added to flat tables.

SQL Command:
Exec [dbo].[pPA_RLSFlatTablesPrepare]
Exec [dbo].[pPA_RLSFlatTablesFill]
Flat tables are maintained by triggers on user security tables:
SQL Command:
exec [dbo].[pPA_RLSCreateTriggers]
To control the access to data in a row, functions are used and referenced to a table as predicates in a security policy.
RLS (Inline table valued) functions are created for all registers that are controlled by permissions:

SQL Command:
Exec [dbo].[pPA_RLSCreateFunctions]
RLS functions are also used to control data on documents that use these registers. For this purpose, common functions are prepared and used in several security policies as predicates on different tables (tHE_Move, tHE_Order, ...).
Security policies are created setting the RLS Functions as predicates on tables:

SQL Command:
Exec [dbo].[pPA_SetRLSFunctionPolicyFill]