如何定义当前用户?

发布于 2024-09-01 03:32:55 字数 181 浏览 4 评论 0原文

是否可以定义当前用户?

我找到了一个存储过程“sp_mgGetConnectedUsers”。它返回一个结果集,其中包含唯一的唯一字段“地址”。我如何将正在执行的查询与这样的“地址”相关联。

请指教。

注意:据我了解,获取当前用户的另一种方法是为每个连接设置唯一的应用程序Id,但我不太喜欢这种方式。

Is it possible to define a current user?

I found a stored procedure 'sp_mgGetConnectedUsers'. It returns a result set with the only unique field 'Address'. How could I associate an executing query with such 'Address'.

Please advice.

Note: As far as I understand, another way to get the current user is to set a unique application Id for each connection, but I don't like this way much.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

揪着可爱 2024-09-08 03:32:55

如果使用数据字典,您可以使用用户标量函数:

select user() from system.iota;

并将其与 sp_mgGetConnectedUsers 返回的 DictionaryUser 字段相关联。

如果不使用字典,最简单的方法是使用 sp_SetApplicationID 和 sp_GetApplicationID。你为什么不喜欢这样呢?如果我们知道您的最终目标是什么,可能会更容易为您提供帮助。如果您只想查看与查询关联的用户,请执行 sp_GetSQLStatements 过程。

If using a data dictionary you can use the user scalar function:

select user() from system.iota;

and correlate that with the DictionaryUser field returned from sp_mgGetConnectedUsers.

If not using a dictionary the easiest way would be to use the sp_SetApplicationID and sp_GetApplicationID. Why don't you like that way? It might be easier to help you if we knew what your final goal was. If you just want to see the user associated with a query, execute the sp_GetSQLStatements procedure.

横笛休吹塞上声 2024-09-08 03:32:55

有多种方法可以考虑当前用户。这取决于您如何使用优势。

sp_mgGetConnectedUsers 输出给出以下内容:
用户名 - 计算机名称
词典用户 - 用于登录 ADS 词典的用户
地址 - IP、IPX 或 IPC 地址
OSUserLoginName - 客户端操作系统登录名
TS 地址 - 客户端地址的最终用户的 IP 地址
ApplicationID - 唯一可设置的 ID 默认 = exe 名称

如果您使用字典并且每个人都使用唯一名称连接字典,那么字典用户将是正确的选择(您也可以通过“从系统中选择 user()”来获取此信息.iota”(或 )用于 sql 脚本等)。地址和用户名将是用户的 IP 地址和用户的计算机名称。这也应该可以帮助您唯一地识别用户。如果您的用户通过终端服务器进入,您可以使用 TS 地址与 OSUserLoginName 结合来识别他们。
我不会详细介绍 ApplicationID,因为您明确表示您不关心此解决方案。但是...虽然您可以将其设置为您想要的任何内容,但默认值是应用程序的名称(即 ARC.exe)。

问题的 B 部分是如何关联查询。 sp_getsqlstatements 过程将返回当前活动查询(或者您可以使用 ARC 中的远程服务器信息)。这将返回与 sp_mgGetConnectedUsers 中的用户名相同的连接名称。使用该组合,您可以得知计算机名称、IP 地址(或终端地址)、字典用户名、客户端操作系统登录名和应用程序名称。

There are multiple ways to think about the current user. It depends on how you use Advantage.

The sp_mgGetConnectedUsers output gives the following:
UserName - Computer Name
Dictionary User - User used to login to the ADS Dictionary
Address - IP, IPX or IPC address
OSUserLoginName - Client OS login name
TS Address - IP address of the end-user of the client address
ApplicationID - Uniquely setable ID default=exe name

If you use a Dictionary and each person connects the Dictionary with a Unique Name then Dictionary User would be the way to go (you can also get this by "select user() from system.iota" (or ) for sql scripts etc). Address and UserName will be the IP Address of the user and Computer Name of the user. This should help you uniquely identify the user as well. If your users are coming in via Terminal server you can use the TS Address to identify them in combination with the OSUserLoginName.
I won't go into detail on ApplicationID since you specifically stated that you didn't care for this solution. But... While you can set this to anything you want the default is the name of the application (i.e. ARC.exe)

Part B of your question is how to associate a query. The sp_getsqlstatements procedure will return the current active queries (or you could use Remote Server Info in ARC). This returns the Connection Name which is the same as UserName from sp_mgGetConnectedUsers. Using the combination you can tell the Computer Name, IP address (or Terminal Adderss), Dictionary UserName, Client OS LoginName, and the application name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文