Solved

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

Posted on 2014-10-28
2
2,724 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
[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 Comments
 
LVL 40

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

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.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

623 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