In this tutorial you will learn how to log user activities in the auditing log.
Open your project with Secure Access authentication implemented. Add a new page called Auditing.aspx.
Add following lines at the beginning of the page code-behind, so that you can use Secure Access libraries in this page.
[Visual Basic] Imports PortSight.SecureAccess.ARDataServices Imports PortSight.SecureAccess.ARObjects [C#] using PortSight.SecureAccess.ARDataServices; using PortSight.SecureAccess.ARObjects; |
Put a new button named "Button1" and a new label named "Label1". Double-click the button and you will see the event handler code for this button. Add following lines to this method:
[Visual Basic] Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ARHelper.Log(User.Identity.Name, "User clicked on the button on the Auditing.aspx page.", "Sample_ButtonClick", "WorkReports") Label1.Text = "The custom action has been logged." End Sub [C#] private void Button1_Click(object sender, System.EventArgs e) { ARHelper.Log(User.Identity.Name, "User clicked the button on the Auditing.aspx page.", "Sample_ButtonClick", "WorkReports"); Label1.Text = "The custom action has been logged."; } |
Compile and run your application. Log on and navigate to the Auditing.aspx page. Click on the button. You should see the text "The custom action has been logged".
Open the Secure Access user interface and choose "Auditing Log". Sort the items descending by date and see the last few records. You should find the information about the action you made.
Tip | ||
---|---|---|
You used the ARHelper class. You can also use the ARConnection.Log method to log information into the auditing log. |