With Dynamics 365, a report titled as mentioned in the subject allows you to see who needs license assignment. This could be because you never purchased the licenses, or you never bothered to assign the licenses to some or all users.
Remember, there is a difference between a License and a Security Role. A security role allows or restricts a user's access to Dynamics. You can also control access to sections, modules, or functionalities by assigning or removing security roles. However, licenses do not technically restrict access (as of now) and are more of a compliance/commercial aspect. If you have not assigned a license to a user, that user can still use Dynamics technically. However, for audit and commercial reasons, you must be compliant and ensure the correct assignment of licenses at all times.
Coming back to the subject, I wanted to know how this report shows the information/data. For a long time, I thought it was through some SQL Stored Procedures, as I saw a few of those a while back. Let's take a closer look.
.
If you look at the report, it is using an RDP class
Look at the Line 47 of the RDP class
Microsoft.Dynamics.AX.Security.LicenseService.SKUAccessService::RefreshUserPrivilegeLicenses(forceRefresh);
Let's go and have a look at that DLL Service named SKUAccessService and it's operation named as RefreshUserPrivilegeLicenses
Let's have a look at the operation named as RefreshUserPrivilegeLicenses under the service SKUAccessService
Looking into the code of operation/method named RefreshUserPrivilegeLicenses it leads us further to another method named RefreshUserLicenses() , as shown in the next method.
The method RefreshUserLicenses() takes us to another method named RefreshUserPrivilegeLicenses() method
Further the method named RefreshUserPrivilegeLicenses() takes us to another method named RefreshUserPrivilegeExplodedGraph() method
The method named RefreshUserPrivilegeExplodedGraph() takes us to another method named PopulateTableUserPrivilegeExplodedGraph()
finally, let's go inside the method name PopulateTableUserPrivilegeExplodedGraph()
As you can see, from the code of the method named PopulateTableUserPrivilegeExplodedGraph() in the previous screenshot, it is calling/executing a store procedure named as License_PopulatTableUserRequiredLicense
Let's go on the SQL Server, and this Store Procedure exists there
The stored procedure truncates the entire table and re-inserts the data into a table named `UserRequiredLicenses`.
This table, into which data is inserted by the stored procedure based on the query, forms the basis for the data displayed in the report.
Let's summarize the flow.
Report >> RDP Class >> Call to DLL/Service [SKUAccessService ] >> Call to service Operation (method named RefreshUserPrivilegeLicenses) >> RefreshUserLicenses() >> RefreshUserPrivilegeLicenses() >> RefreshUserPrivilegeExplodedGraph() >>PopulateTableUserPrivilegeExplodedGraph >> Call to the Store Procedure License_PopulatTableUserRequiredLicense >> Delete data (and re-insert into the base table)
This happens every time you run the report, before report injects the data into the Temp Table (at line 47, that line number may change in thefuture versions)
If you want to see the flow in functional way or as picture , here it.