Audit Entity / Table – Few key points (Dynamics 365 / Power Apps)


In the earlier post we looked at different ways of extracting Audit History data.

Extract Audit Historyhttps://nishantrana.me/2021/05/17/how-to-export-the-audit-history-values-from-dynamics-365/

We can use Microsoft 365 Security and Compliance Center for the same, though it is limited to the Production environment only.

https://docs.microsoft.com/en-us/power-platform/admin/enable-use-comprehensive-auditing#requirements

Then we have Audit History Extractor, and we can also write SSIS Packages as well as Custom Code.

Let us just revisit some of the key points with regards to the Audit entity.

  • Do we have the Audit entity available for Advanced Find? >> No.

  • Do we have it available inside Report Wizard? >> No.

  • Can we write SSRS Report against the Audit entity using the TDS endpoint?

Let us create the Data Source.

Select the authentication as Active Directory Password Authentication for the TDS endpoint.

Enter the database name manually.

The final connection string >>

Data Source=orgnamae.crm.dynamics.com;Initial Catalog=orgname.crm.dynamics.com;Encrypt=True;TrustServerCertificate=False;Authentication=”Active Directory Password”

Within SQL4CDS the following query works

However, the same query doesn’t work inside SSRS.

It will give the below error message >>

Table audit is not available for reports

  • Do we have the Audit entity in the Power BI Dataverse connector? >> No

However, we can use the OData endpoint to create the report against the Audit entity.

https://www.365knowledge.com/2019/03/06/dynamics-365-user-access-report-with-fetchxml-and-power-bi/

  • Do we have the Audit entity available in Azure Synapse Link (Export to Data Lake)? >> No

How to set up Azure Synapse Link >>

https://nishantrana.me/2021/06/16/how-to-setup-azure-synapse-link-microsoft-dataverse/

  • Cannot we write a Fetch XML Based SSRS report?

Writing a Fetch XML based-report would be challenging, because of the way information is saved.

Check the below article to understand how the audit table stores the information.

https://mahadeomatre.blogspot.com/2015/02/ms-crm-audit-database-table-details.html

http://makdns.blogspot.com/2014/06/dynamics-crm-audit-entity.html

  • How about SQL Based SSRS Report if we are using SQL – for On-Premise?

Refer to the below article that provides the steps to do so.

http://makdns.blogspot.com/2014/06/dynamic-crm-20112013-audit-report-in.html

Hope it helps..

Advertisements

Activity Logging – Dynamics 365 Apps


Microsoft 365 Security and Compliance Center – provides easy access to the data and the tools to manage the compliance need of an organization, and also can be used to review the different data processing activities within Dynamics 365 Customer Engagement apps.

It required Microsoft 365 E3 or E5 subscription and is only available for Production environments.

The events logged are –

  • CRUD, Export to Excel, SDK Calls.
  • CRUM and backend activities performed by the support engineer.
  • Report – viewed, exported, multimedia assets shown in the Report

For this first Auditing needs to be enabled in the environment.

Navigate to Settings > Administration > System Settings > Auditing Tab

Navigate to Compliance Center

https://protection.office.com/

Search > Audit Search Log and
Turn on auditing.



To try the new experience within the Compliance center

https://compliance.microsoft.com/auditlogsearch?viewid=Search


After around 1 hour or so, the settings got enabled.


As specified Office 365 logs are being prepared, if we try searching we’d get blank results


Below are the list of Dynamics 365 and Power Apps activities that can be tracked


Around after 3 hours or so – we saw the results appearing.

Export has 2 options –

Save loaded results –

Download all results –

At the same time there we 51 records in Audit Summary View.

Apart from searching for an audit log, we can also define an audit retention policy as shown below

Get the sample files here –

https://drive.google.com/file/d/1akifraP1NCV-KgmA-8ROhm8r4h0tAcLi/view?usp=sharing

https://drive.google.com/file/d/1s_EbJ4hraDl6YEVUCMkOe6bQbXCJu_5-/view?usp=sharing

Get all the details here

https://docs.microsoft.com/en-gb/microsoft-365/compliance/search-the-audit-log-in-security-and-compliance?view=o365-worldwide

Hope it helps..

Advertisements

Using RetrieveRecordChangeHistoryRequest to get Audit Detail in Dynamics 365 CE


Just sharing a sample code to retrieve the Audit Detail using RetrieveRecordChangeHistoryRequest.

</p>
<p>RetrieveRecordChangeHistoryRequest changeRequest = new RetrieveRecordChangeHistoryRequest();<br />
changeRequest.Target = new EntityReference("entitySchemaName", "entityId"));<br />
RetrieveRecordChangeHistoryResponse changeResponse =<br />
(RetrieveRecordChangeHistoryResponse)_service.Execute(changeRequest);</p>
<p>AuditDetailCollection auditDetailCollection = changeResponse.AuditDetailCollection;</p>
<p>foreach (AttributeAuditDetail attrAuditDetail in auditDetailCollection.AuditDetails)<br />
{<br />
var auditRecord = attrAuditDetail.AuditRecord;</p>
<p>Console.WriteLine("Entity: " + ((EntityReference)auditRecord.Attributes["objectid"]).LogicalName);<br />
Console.WriteLine("Operation: " + auditRecord.FormattedValues["operation"]);<br />
Console.WriteLine("Action: " + auditRecord.FormattedValues["action"]);</p>
<p>var newValueEntity = attrAuditDetail.NewValue;</p>
<p>foreach(var attrNewValue in newValueEntity.Attributes)<br />
{<br />
Console.WriteLine("New Key: " + attrNewValue.Key + "New Value: " + attrNewValue.Value);<br />
}</p>
<p>var oldValueEntity = attrAuditDetail.OldValue;</p>
<p>foreach (var attrOldValue in oldValueEntity.Attributes)<br />
{<br />
Console.WriteLine("Old Key: " + attrOldValue.Key + "Old Value: " + attrOldValue.Value);<br />
}<br />
}</p>
<p>

The record whose Audit History we are retrieving :

Output :

AuditDetail.AuditRecord :

AuditDetail.OldValue n NewValue:

Hope it helps..

Advertisements