Skip to content

Instantly share code, notes, and snippets.

@arcanadev
Created February 18, 2021 22:37
Show Gist options
  • Save arcanadev/f9373e4437340764729f65d8c0a046a1 to your computer and use it in GitHub Desktop.
Save arcanadev/f9373e4437340764729f65d8c0a046a1 to your computer and use it in GitHub Desktop.
Query the change log #adtempus #api #version4

The sample demonstrates how to query the adTempus Change Log (audit log) to report on tracked changes to adTempus configuration.

Note that auditing must be configured properly for adTempus.

using (var session = Scheduler.Connect(ServerName, LoginAuthenticationType.Windows, "", ""))
{
var parms=new ChangeLogQueryParameters();
parms.ExcludeSystemGenerated=true; //don't include changes made by the system, e.g., jobs held by job control action
parms.IncludeObjectDescriptions=true; //resolve the objects and populate the ObjectDescription field. Otherwise it will be empty.
parms.AuditOnly=true; //exclude records that were just snapshots
//query the last 7 days of changes
parms.EndTimestamp=DateTime.Now;
parms.StartTimestamp=parms.EndTimestamp.Value.Subtract(TimeSpan.FromDays(7));
var records = session.QueryChangeLog(parms);
foreach (var record in records)
{
Console.WriteLine($"{record.Timestamp:yyyy-MM-dd HH:mm:ss}. Action: {record.ChangeType}. Object: {record.ObjectDescription}. User: {record.SecurityLogin.Name}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment