Solved

Track IP address of user accessing tables in SQL Server 2008 R2 Audit

Posted on 2014-10-28
2
2,402 Views
Last Modified: 2014-10-29
I am trying to use audit feature of SqlServer 2008R2 and able to get the details of logged in user and also when he fires any query in DB.
I am also able to get the IP address in additional_information column in xml form.
My problem is I can get the IP address only when he logged in to the sql server, but when he fires any query the additional_information column is blank, so I am unable to get the machine details from which this query is fired.
Problem may occur when two different users use same login credentials and fire query, then it is impossible for me to find which user fired which query
In Server Audit Specification I am using SUCCESSFUL_LOGIN_GROUP and SCHEMA_OBJECT_ACCESS_GROUP.

Thanks in Advance....
0
Comment
Question by:ziorinfo
2 Comments
 
LVL 39

Accepted Solution

by:
lcohan earned 500 total points
ID: 40410773
You can use these inside SQL and as each connection binds to a SPID you should be able to get the client IP:

SELECT hostname, net_library, net_address FROM sys.sysprocesses
where len(hostname)>0

SELECT client_net_address as IP_Address FROM sys.dm_exec_connections
0
 

Author Comment

by:ziorinfo
ID: 40412538
Thanks for the solution, it worked. Can I differentiate between the logs which are entered through my website and directly from sql server.
Actually when any user visits my website, that record is also stored in the Audit log and only session id is different in this case which is not sufficient for me to track which log is entered from application front end and which from sql server query.

Thanks
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to shrink a transaction log file down to a reasonable size.

808 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