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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:18:43+00:00 2026-05-22T22:18:43+00:00

In order to perform auditing on a SQL 2008 database for updates / insert

  • 0

In order to perform auditing on a SQL 2008 database for updates / insert / delete, I was accessing

HttpContext.Current.User

in the datalayer to pass to a stored proc which would set the CONTEXT_INFO for auditing triggers.

These is probably wrong because if I wanted to put another UI (i.e. WinForms) the HttpContext wouldn’t apply, however I don’t want to add a username parameter to my BLL methods or add a constructor as all these methods are static. What is the best way to access a user identity in the DAL?

  • 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-22T22:18:44+00:00Added an answer on May 22, 2026 at 10:18 pm

    You should use the static Thread.CurrentPrincipal property. Notice however that this property might not be equal to HttpContext.Current.User depending on your web application’s impersonation settings.

    A good solution might be to first check whether HttpContext.Current is not null. If it isn’t then read the user from there, and otherwise fallback to reading Thread.CurrentPrincipal.

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

Sidebar

Related Questions

In order to perform a case-sensitive search/replace on a table in a SQL Server
How would I go about drawing a view offscreen in order to perform some
What steps I need to perform in order to convert asp.net 2 application from
Here is my desired transaction order: User1 select field, perform operation, update with new
In order to know how many times a pattern exists in current buffer, I
We currently use Auditing triggers to track all of our DB changes. In order
In order to perform a simple clustering algorithm on results that I get from
I am using a third-party API (Spreadshirt's API) and in order to perform a
In order to perform basic charting from a windows service (win32 API) including the
I would like to call other Perl scripts in order to perform a contention

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.