?
Solved

Syntax/Sql

Posted on 2005-03-08
7
Medium Priority
?
213 Views
Last Modified: 2010-05-02
We have an application where users login using their Windows Authentication user name , but the connection goes to the database using a generic userid "ABC123" for all the users. My question is , when a user makes some changes to the data , like insert , update,delete ...is there a way to find out who did the change.

Right now when i use "sp_who" or DBArtisan for Oracle ...alll i can see is "ABC123" ....i want to know which exact user did the transaction based on his/her login.
I need the syntax and the way it can be incorporated in code using VB.6

Any help in this matter is greatly appreciated , please let me know in detail .

many thanks.
0
Comment
Question by:crishna1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
7 Comments
 
LVL 14

Accepted Solution

by:
aelatik earned 1500 total points
ID: 13489412
Within the VB application when a database command occures just insert to a new table the name of the user and the executed SQL statement.
To fetch the windows authenticated username use :

Environ("USERNAME")
0
 

Author Comment

by:crishna1
ID: 13489603
Is this T-SQL or PL/SQL?
0
 
LVL 8

Expert Comment

by:fatalXception
ID: 13489703
If the actual database service is being run by this "ABC123" user then I'm not sure that you can get it automatically - I do know that Oracle stores the OS username for inserts, etc, but I'm failry sure (don't qoute me) that it's the username submitted by the service

The command
select osuser from v$session;

will give you back the connected users, so for example you could in a Stored procedure determine the username from Windows, but I'm not sure if this will work for you.
0
 

Author Comment

by:crishna1
ID: 13497775
may be the following will make it simpler.

For instance,

 I have a column ( say MODIFIER) in every table in the database
which is deafulted to SUSER_SNAME( ) for Sql Server and USER for Oracle.

When i do a sp_who2 , it returs me the user as ABC and the hostname.

Instead of defaulting this coulmn to SUSER_SNAME or USER , how can i default it to the Hostname?
(I am guessing it can be done through a user defined function or something like that)
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question