Sql server,获取网络上的几个用户的IP,所有用户都使用sa登录? [英] Sql server, get IP of several users on the network which all of them are logged in with sa ?

查看:325
本文介绍了Sql server,获取网络上的几个用户的IP,所有用户都使用sa登录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在sql server中,当你使用cmdshell获取ipconfig时,它返回运行数据库引擎的机器的ip地址。

但是我有一个sql server引擎和多个用户通过网络使用自己的应用程序,他们所有的应用程序都使用sa登录,所以当他们运行我的sp获取他们的ipconfig时,它返回主机的ip地址。

如何使用自己的IP地址。



让我们说它会在我的日志表中给我一个记录,如:



日期|时间|登录用户名|用户IP地址



我不知道如何实现它。



任何帮助或建议会很有帮助,我很感激,



谢谢,



我是什么尝试过:



我现在正在阅读cmdshell,但我还是没有找到答案。

Hi,
In sql server when you get the ipconfig using the cmdshell it returns the ip address of the machine which the database engine is running on.
but I have one sql server engine and multiple users over the network with their own applications, all of their applications are using the sa login, so when they run my sp to get their ipconfig it returns the ip address of the main machine.
how can I take their own ip addresses.

Lets say it's going to give me a record in my log table like;

Date | Time | Login UserName | user ip address

and I don't know how to achieve it.

any help or advice would be helpful and I'm grateful for that,

thanks,

What I have tried:

I'm reading the cmdshell right now but I still haven't found an answer for it.

推荐答案

因此,在正常使用应用程序时,您有多个人在SQL Server中使用SA帐户?您是想通过意外还是恶意销毁数据库?



这是一个巨大的安全风险。除了初始设置SQL服务器之外,NOONE应该使用SA帐户。
So you've got multiple people using the SA account in SQL Server in the normal use of applications? Are you looking to have your databases destroyed either by accident or malice?

That's is a MASSIVE security risk. NOONE should be using the SA account for anything except the initial setup of the SQL server.


您好,



这可能是一个漫长的过程,但你可以获得用户名的IP地址



首次运行

select * from sys.dm_exec_connections order by session_id

从上面你将获得会话ID,client_net_address



现在你在sp_who中检查会话ID以确定谁是用户。



谢谢,
Hi,

This could be a long process but you can get ip address with user name

first run
select * from sys.dm_exec_connections order by session_id
from above you will get session id,client_net_address

Now you have check with session id in sp_who to identify who is the user.

Thanks,


这篇关于Sql server,获取网络上的几个用户的IP,所有用户都使用sa登录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆