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 6776389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:01:26+00:00 2026-05-26T16:01:26+00:00

Just stumbled across the new ClientId (aka client_identifier) variable that is available in Oracle

  • 0

Just stumbled across the new ClientId (aka client_identifier) variable that is available in Oracle 10g onwards, and would love to incorporate that into an app to assist with audit trails.

The app is using a generated Enterprise Library DAAB based layer (netTiers) that is wired to use the ODP.NET drivers with EntLibContrib, so CRUD functions create an OracleDatabase object and then retrieve generic DbCommand objects from it

It looks like the OracleConnection class has the ClientId property, so what is the cleanest way to get to the Connection object within that pattern? Should I be grabbing the connection out of every DbCommand I create and setting it there, or is that overkill?

Because EntLib is doing much of the connection management behind the scenes, I’m not sure whether I can set the ClientId somewhere outside of the CRUD functions and expect it to persist?

  • 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-26T16:01:26+00:00Added an answer on May 26, 2026 at 4:01 pm

    If the connection is a partial class you can implement a trigger that sets the client id whenever the connection changes state to open.
    That’s the way I implemented it.

    I don’t know if you can use part of this:

    public partial class DataContext
    {
        partial void OnContextCreated()
        {
            if ( null == this.Connection ) return;
    
            this.Connection.StateChange += Connection_StateChange;
        }
        private EntityConnection EntityConnection
        {
            get { return this.Connection as EntityConnection; }
        }
        private OracleConnection OracleConnection
        {
            get { return this.EntityConnection.StoreConnection as OracleConnection; }
        } 
        private void Connection_StateChange( object sender, StateChangeEventArgs e )
        {
            if ( e.CurrentState != ConnectionState.Open ) return;
    
            OracleConnection conn = this.OracleConnection;
            if ( null == conn ) return;
    
            //closes connection on DataContext (bug?), and passes closed/broken connection 
            //conn.ClientId = HttpContext.Current == null ? "Anonymous" : HttpContext.Current.Profile.UserName;
    
            //working solution
            string identity = HttpContext.Current == null ? "Anonymous" : HttpContext.Current.Profile.UserName;
            OracleCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "DBMS_SESSION.SET_IDENTIFIER";
            cmd.Parameters.Add( new OracleParameter { ParameterName = "client_id", Value = identity } );
            cmd.ExecuteNonQuery();
            cmd.Dispose();
    
            return;
        }
    
        protected override void Dispose( bool disposing )
        {
            if ( null != this.Connection )
                this.Connection.StateChange -= Connection_StateChange;
    
            base.Dispose( disposing );
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to Qt and stumbled across a problem that I could not
I just stumbled across an assert that failed, as it compared false to the
I just stumbled across this bug in some legacy code: class MyAPIHandler { private:
I just stumbled unto a weirdness in my JSP code. It seems that a
I'm working on porting some classic VB6 code to C# and just stumbled across
I'm familiar with $get() and $find() . But, I've just stumbled across some code
I have just stumbled across the Backgroundworker object, and it seems like the tool
I've just stumbled across this fascinating article on the BBC website regarding producing music
I just stumbled across the concept of a Web Garden in an IIS App
hey guys, i'm almost sure that i've stumbled across a plugin like that. i

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.