





















































This article is written by Ahmed Mohamed Rafik Moustafa, the author of Microsoft Dynamics AX 2012 R3 Security. In any corporation, some users are restricted to work with specific sensitive data because of its confidentiality or company policies, and this type of data access authorization can be managed using extensible data security (XDS). XDS is the evolution of the record-level security (RLS) that was available in the previous versions of Microsoft Dynamics AX. Also, Microsoft keeps the RLS in version AX 2012, so you can refer to it at any time.
The topics that will be covered in this article are as follows:
(For more resources related to this topic, see here.)
When developing an XDS policy, you need to be familiar with the following concepts:
Concept |
Description |
Constrained tables |
A constrained table is the table or tables in a given security policy from which data is filtered or secured, based on the associated policy query. |
Primary tables |
A primary table is used to secure the content of the related constrained table. |
Policy queries |
A policy query is used to secure the constrained tables specified in a given extensible data security policy. |
Policy context |
A policy context is a piece of information that controls the circumstances under which a given policy is considered to be applicable. If this context is not set, then the policy, even if enabled, is not enforced. |
After understanding the previous concepts of XDS, we move on to the four steps to develop an XDS policy, and they are as follows:
XDS is a powerful mechanism that allows us to express and implement data security needs. The following steps show detailed instructions on designing and developing XDS:
Now we have to create the policy itself. Follow these steps:
The following screenshot displays the properties:
After designing the query and developing the required policy, the next step is to add the constrained tables and views that contain the data by using the created policy.
By following the next steps, you will be able to add constrained tables or views:
When adding the constrained table AssetBook, you must determine the relationship that should be used to join the primary table with the last constrained table.
Repeat these steps for every constrained table or view that needs to be secured through this policy.
After finishing these steps, the policy will be applied for all users who are attempting to access the tables or views that are located on the constrained table's node when the Enabled property is set to Yes. Security policies are not applied to system administrators who are in the SysAdmin role.
According to the requirements, the security policy needs to be adjusted to apply only to the users who were assigned to the vendor role. The following steps should be performed to make the appropriate adjustment:
To assign this policy to all the vendor roles, the ForAllVendorRoles context should be applied to the appropriate roles:
For more information, go to MSDN and refer to Whitepapers – Developing Extensible Data Security Policies at https://msdn.microsoft.com/en-us/library/bb629286.aspx.
One of the most common issues reported when a new XDS policy is deployed is that an unexpected number of rows are being returned from a given constrained table. For example, more sales orders are being returned than expected if the sales order table is being constrained by a given customer group.
XDS provides a method to debug these errors. We will go over it now.
Review the SQL queries that have been generated. The X++ select has been extended with a command that instructs the underlying data access framework to generate the SQL query without actually executing it.
The following job runs a select query on SalesTable with a generated command. It then calls the getSQLStatement() method on SalesTable and dumps the output using the info API.
static void VerifySalesQuery(Args _args) { SalesTable salesTable; XDSServices xdsServices = new XDSServices(); xdsServices.setXDSContext(1, ''); //Only generate SQL statement for custGroup table select generateonly forceLiterals CustAccount, DeliveryDate from salesTable; //Print SQL statement to infolog info(salesTable.getSQLStatement()); xdsServices.setXDSContext(2, ''); }
The XDS policy development framework further eases this process of doing some advanced debugging by storing the query in a human-readable form. This query and others on a given constrained table in a policy can be retrieved by using the following Transact-SQL query on the database in the development environment (AXDBDEV in this example):
SELECT [PRIMARYTABLEAOTNAME], [QUERYOBJECTAOTNAME], [CONSTRAINEDTABLE], [MODELEDQUERYDEBUGINFO], [CONTEXTTYPE],[CONTEXTSTRING], [ISENABLED], [ISMODELED] FROM [AXDBDEV].[dbo].[ModelSecPolRuntimeEx]
This SQL query generates the following output:
As you can see, the query that will join the WHERE statement of any query to the AssetBook table will be ready for debugging. Other metadata, such as LayerId, can be debugged if needed.
When multiple policies apply to a table, the results of the policies are linked together with AND operators.
By the end of this article, you are able to secure your sensitive data using the XDS features. We learned how to design and develop XDS policies, constrained tables and views, primary tables, policy queries, set the security context, run SQL queries and learned how to debug XDS policies.
Further resources on this subject: