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

  • SEARCH
  • Home
  • 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 721889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:55:31+00:00 2026-05-14T05:55:31+00:00

We have audit columns set by triggers. For obscure security reasons predating my tenure

  • 0

We have audit columns set by triggers.
For obscure security reasons predating my tenure and out of my control, we log in with a generic user, and do a ‘set session authorization’ to change the user to the db user of the user who is logged in.

When we converted to NHibernate, it creates a whole new session and jacks everything up
when we try to do a set session auth, so we turned the set session auth off…

Now we are trying to find out a way to get NHibernate to let us do ‘set session authorization’ without recycling the session on us, so we can use our existing trigger based audit column stuff with both legacy apps, and our new NHibernate apps.

It’s not a ideal soloution, or the best way to do it even, but is it possible?

I was hoping there was a alternate interface that allowed this kind of access.

Does anyone know how to do it, or can you point me towards and good hints?

Thanks,

Eric-

  • 1 1 Answer
  • 0 Views
  • 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-14T05:55:32+00:00Added an answer on May 14, 2026 at 5:55 am

    You can inherit DriverConnectionProvider and do whatever you need when creating a connection.

    Example:

    public class MyConnectionProvider : DriverConnectionProvider
    {
        public override IDbConnection GetConnection()
        {
            var connection = base.GetConnection();
            var sessionAuthCommand = connection.CreateCommand();
            sessionAuthCommand.CommandText = "set session authorization " + GetUser();
            sessionAuthCommand.ExecuteNonQuery();
            return connection;
        }
    }
    

    And then configure NHiberate to use that as the connection provider.

    (GetUser is the method where you’ll provide the correct user)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have certain initializing functions that I use to set up audit logging on
I have audit for records in a table. There multiple columns and each records
I have been researching audit triggers for some of my sql tables. I came
All of my tables have certain audit columns (CreateDate,CreateBy,UpdateDate,UpdateBy) Since they just take up
I have an audit table and I'm trying to use Linq to figure out
I have an audit record table that I am writing to. I am connecting
I have a table called 'Audit' in SQL Server 2005 like this: Name |
I have many domain classes in my application an for Audit logging I need
I have a quick question. I'm have a db an audit Table with a
I have a trigger in SQL Server 2005 that is used to track audit

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.