locked
Auditing RRS feed

  • Question

  • User-1024202203 posted

    How to create an audit tool that tracks and records(what're changed? by whom? when?). the changes of any fields with their old and new values using an ASP.NET-Vb.Net web page.I am looking in MySql Database.I have two tables/two web forms in my project  1.user loginform and 2.Main form(Performing CRUD operations).

    Friday, January 22, 2010 3:42 AM

Answers

  • User-952121411 posted

    Well one common easy way to manage this is to add (2) simple fields to the end of the applicable table(s) as follows:

    LastUser

    LastUpdate

    Now if your ASP.NET app uses impersonation in the web.config and you are using Windows Authentication, you can easily extract the user name upon the client opening the application.  Then combine this username with a SQL 'GetDate()' call for the LastUpdate column, and you are done.  The GetDate() call can be in your stored procedure so you don't have to deal with it in your app, and the UserName can be passed in as a parameter.

    If you don't use Windows Authentication, just use whatever user loggs on via forms authentication, etc. and send that along to your database when applicable.

    There are more elaborate solutions, but this can get you up and running easily and quickly.

    Hope this helps! Smile

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 22, 2010 10:57 PM

All replies

  • User197322208 posted

    I think that auditing is better to be in database.

    However, if you want to audit from your application , please put the logic in a different class and log the events on this class

    Example :

    Suppose you have this:

    public Sub ButtonSave_Click()

     'crud operation for insert employee - name

    end sub

    you will do something like

    Public class Employee

    Public Name as string

    Public Sub Save()

    ' TODO : log

     'copy here crud operation for insert employee - name

    end sub

    End class

    and modify the save button click

    public Sub ButtonSave_Click()

    Dim emp as Employee = new Employee()

    emp.Name = ...

    emp.Save()

    end sub

    Friday, January 22, 2010 7:19 AM
  • User-952121411 posted

    Well one common easy way to manage this is to add (2) simple fields to the end of the applicable table(s) as follows:

    LastUser

    LastUpdate

    Now if your ASP.NET app uses impersonation in the web.config and you are using Windows Authentication, you can easily extract the user name upon the client opening the application.  Then combine this username with a SQL 'GetDate()' call for the LastUpdate column, and you are done.  The GetDate() call can be in your stored procedure so you don't have to deal with it in your app, and the UserName can be passed in as a parameter.

    If you don't use Windows Authentication, just use whatever user loggs on via forms authentication, etc. and send that along to your database when applicable.

    There are more elaborate solutions, but this can get you up and running easily and quickly.

    Hope this helps! Smile

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 22, 2010 10:57 PM