How would you check ASP.NET membership tables when recording that a user made a change?

Using the trigger approach to audit logging, I record the history of changes made to tables in the database. The approach I use (with the static sql server name) to record which user made the changes involves starting the stored procedure at the beginning of each connection to the database. Triggers use this username when recording audit strings. (Triggers are provided by OmniAudit.)

However, ASP.NET membership tables are available mainly through the membership API. I need to pass the current user id when the membership API opens the database connection. I tried subclassing the MembershipProvider, but I cannot access the underlying database connection.

This seems to be a common problem. Does anyone know of any hooks we can get when ASP.NET membership makes a database connection?

+2
source share
1 answer

Update 2: I'm not afraid to look bad on the AOP front - see Is it possible to intercept the static method for an object that you do not have and did not create?

, , Toolkit SqlConnectionHelper.GetConnection()

, , . 4.0 , .


:

, , , , :

, ?

SqlMembershipProvider System.Web.DataAccess.SqlConnectionHolder .

, , , AOP, Castle DynamicProxy ( , ), .

- ?


:

SqlMembershipProvider. , .

string connectionString = 
   typeof(SqlMembershipProvider)
   .GetField("_sqlConnectionString",BindingFlags.NonPublic | BindingFlags.Instance)
   .GetValue(Membership.Provider);
+1

Source: https://habr.com/ru/post/1747177/


All Articles