且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过SQL身份验证连接时如何获取域名用户名

更新时间:2022-12-07 23:39:45

您不能。简单。 SQL Server完全不了解具有SQL登录

You can't. Simple. SQL Server has no knowledge of the end user with a SQL login at all

如果您使用代理(Web服务器等),则同样适用也:您不了解最终用户。我们使用参数/存储的proc来从Web服务器传递用户名。

The same applies if you use a proxy (web server etc) too: you don't know the end user. We use parameters/stored procs to pass in the username from the web server.

我建议您在客户端中设置CONTEXT_INFO,以保持该连接。

I would suggest that you set CONTEXT_INFO in the client which persists for that connection.