Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-10-28
2
Medium Priority
?
3,088 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 40

Accepted Solution

by:
lcohan earned 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

783 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