Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 814357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:30:28+00:00 2026-05-15T01:30:28+00:00

Using a trigger-based approach to audit logging, I am recording the history of changes

  • 0

Using a trigger-based approach to audit logging, I am recording the history of changes made to tables in the database. The approach I’m using (with a static sql server login) to record which user made the change involves running a stored procedure at the outset of each database connection. The triggers use this username when recording the audit rows. (The triggers are provided by the product OmniAudit.)

However, the ASP.NET Membership tables are accessed primarily through the Membership API. I need to pass in the current user’s identity when the Membership API opens its database connection. I tried subclassing MembershipProvider but I cannot access the underlying database connection.

It seems like this would be a common problem. Does anyone know of any hooks we can access when the ASP.NET Membership makes its database connection?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:30:29+00:00Added an answer on May 15, 2026 at 1:30 am

    Update 2:
    Not looking good on the AOP front, I am afraid – see Is is possible to intercept a static method on an object you don't own and did not create?

    And as alluded to in comments, it looks like the best bet is to use the Provider Toolkit’s implementation of the providers and wire your hook into SqlConnectionHelper.GetConnection()

    I use the toolkit code, which I have cleaned up considerably, reliably for years with no problems. Let me confirm on 4.0 and package it up if you are interested.


    Update:

    Ok, I think I better understand your need, tell me if I am correct:

    You need the actual connection that is being used by the provider?

    SqlMembershipProvider utilizes a helper class, System.Web.DataAccess.SqlConnectionHolder, for all of it’s data access.

    I have not done this, but from what I have gathered, you could intercept calls to build this object using an AOP implementation such as Castle DynamicProxy (or one of the libraries that leverage it) and get your connection there.

    Could some one with more experience confirm or deny this?


    Original answer:

    No need to derive from SqlMembershipProvider. Just go in and get what you need.

    string connectionString = 
       typeof(SqlMembershipProvider)
       .GetField("_sqlConnectionString",BindingFlags.NonPublic | BindingFlags.Instance)
       .GetValue(Membership.Provider);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to distribute reports based on a database insert trigger, using the
i have a problem with using cron trigger in Quartz.net. My code: var trigger
I have been using State machine based design tools for some time, and have
This is a follow up based on this question about query optimization . In
I'm building a personal Web application using Java EE 6 Technologies (the container is
I created a 3x3 table. Each column is generated using a function. The function
I have stack panel containing three textblocks bounded with different member variable.I want to
I've read up on the Async Page and it's usage, looks simple: [UPDATE] Taken
I have a main view that divided into 4 equally sized sub-views. I used
Here's the scenario, I have events happening from within an iframe and up until

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.