Click here to Skip to main content
15,888,454 members
Home / Discussions / Database
   

Database

 
GeneralRe: Oracle vs SQL server Pin
E_Gold25-Mar-09 19:14
E_Gold25-Mar-09 19:14 
GeneralRe: Oracle vs SQL server Pin
Eddy Vluggen25-Mar-09 21:53
professionalEddy Vluggen25-Mar-09 21:53 
QuestionHow to preserve databinding in a ToolStripDropDown? Pin
SSDiver211225-Mar-09 9:44
SSDiver211225-Mar-09 9:44 
QuestionHow to Upgrade Access databse to MSSQL2005? Pin
Sr...Frank25-Mar-09 1:14
Sr...Frank25-Mar-09 1:14 
AnswerRe: How to Upgrade Access databse to MSSQL2005? Pin
Eddy Vluggen25-Mar-09 5:26
professionalEddy Vluggen25-Mar-09 5:26 
QuestionExtremely slow SP execution in Asp.net Pin
totig25-Mar-09 0:47
totig25-Mar-09 0:47 
AnswerRe: Extremely slow SP execution in Asp.net Pin
totig25-Mar-09 1:14
totig25-Mar-09 1:14 
QuestionAudti triggers - How to get the user name into the audit table [modified] Pin
Simon P Stevens24-Mar-09 1:54
Simon P Stevens24-Mar-09 1:54 
I have written some triggers that fire when data is updated/inserted/deleted. These triggers write entries to the Audit tables.

I want to include the username of the person who made the change. I started by using SUSER_SNAME which works great on the surface.

The trouble is that our system is n tier. There is a business logic server that does all of the access to the database. users access the system via a client app which communicates with the BLL server which writes to the database. Users never communicate with the database directly. This means that the audit logs all have "serveruser" in them, which is the user the server runs under.

Is there any way I can get the audit logs to reflect the user that told the server to make the change, rather than the user that the server is running under.

We don't use stored procedures (we are using a combination of the entity framework and parametrized queries) so we can't just pass the user name to them and let them do it.

(Perhaps is there something to do with impersonation that would do this? I don't want to grant access to the database to any normal users though.)

(I'm using SQL server 2000 and .net 3.5)

Any ideas?

[Edit: I have a solution.

Include a LastModifiedBy field on the table. This value is then set by the server to match the user that made the call to the server. This field is then accessible from the trigger so can be set into the audit table.

What do people think of that solution? Does it sound sensible? Are there any pitfalls of this I should be aware of?]

Simon

modified on Tuesday, March 24, 2009 8:44 AM

AnswerRe: Audti triggers - How to get the user name into the audit table Pin
Pete O'Hanlon24-Mar-09 2:15
mvePete O'Hanlon24-Mar-09 2:15 
GeneralRe: Audti triggers - How to get the user name into the audit table Pin
Simon P Stevens24-Mar-09 2:35
Simon P Stevens24-Mar-09 2:35 
QuestionCalling oracle stored procedure for crystal report Pin
Girish48124-Mar-09 0:32
Girish48124-Mar-09 0:32 
QuestionHow to store an image in PostGresDB? Pin
sunilsb23-Mar-09 22:58
sunilsb23-Mar-09 22:58 
QuestionSome Oracle Question Pin
E_Gold23-Mar-09 8:26
E_Gold23-Mar-09 8:26 
AnswerRe: Some Oracle Question Pin
scottgp23-Mar-09 10:20
professionalscottgp23-Mar-09 10:20 
GeneralRe: Some Oracle Question Pin
E_Gold23-Mar-09 10:51
E_Gold23-Mar-09 10:51 
GeneralRe: Some Oracle Question Pin
scottgp23-Mar-09 15:21
professionalscottgp23-Mar-09 15:21 
Questionwhat is mean by transaction in database? Pin
Ali_10023-Mar-09 7:04
Ali_10023-Mar-09 7:04 
Answertransaction as defined in Wikipedia Pin
David Mujica23-Mar-09 7:54
David Mujica23-Mar-09 7:54 
GeneralRe: transaction as defined in Wikipedia Pin
Ali_10023-Mar-09 10:26
Ali_10023-Mar-09 10:26 
GeneralROLLBACK Pin
David Mujica23-Mar-09 11:00
David Mujica23-Mar-09 11:00 
QuestionItem Stock detail using sale and purchase table [modified] Pin
adeelidrees23-Mar-09 2:36
adeelidrees23-Mar-09 2:36 
QuestionSqlDataReader Number of Rows Pin
Jasmine Pomelo23-Mar-09 2:05
Jasmine Pomelo23-Mar-09 2:05 
AnswerRe: SqlDataReader Number of Rows Pin
Eddy Vluggen23-Mar-09 2:20
professionalEddy Vluggen23-Mar-09 2:20 
GeneralRe: SqlDataReader Number of Rows Pin
Jasmine Pomelo23-Mar-09 2:28
Jasmine Pomelo23-Mar-09 2:28 
GeneralRe: SqlDataReader Number of Rows Pin
Eddy Vluggen23-Mar-09 2:55
professionalEddy Vluggen23-Mar-09 2:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.