Solved

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

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Suggested Solutions

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now