Solved

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

Posted on 2014-10-28
2
2,349 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

770 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