确定谁连接到应用程序 [英] Determine who is connected to application

查看:79
本文介绍了确定谁连接到应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种确定谁连接到Windows应用程序的方法.首先,我查看了连接到sql服务器的用户,但我读到的内容仅显示活动用户.因此,我想我需要一种在用户登录表时存储用户名,但在用户注销时将其删除的方法.

我最终将要将此信息放入列表框或datagridview

我知道ENVIRONMENT.USERNAME,但不确定如何执行此操作.

I am looking for a way to determine who is connected to my windows application. First I looked at who was connected to the sql server but I read that will only show active users. So I guess I need a way to store the username when they log in into a table but remove it when they log off.

I will eventually want to put this information into a listbox or datagridview

I know ENVIRONMENT.USERNAME but not sure how to do this.

推荐答案

AFAIK Environment.UserName仅向其运行的特定计算机上的操作系统用户提供权限.

(不知道那里发生了什么,中途中断了)

因此,您的程序可以调用Environment.UserNameMy.User.Name并将该信息发送到数据库,该数据库可以存储计算机名称,用户名和时间.

(这真是第二次很奇怪)
然后在OnFormClosing事件处理程序中再次调用它,并将其发送到可以存储注销时间的服务器.

可能有比这更好的解决方案,但这应该可行.
AFAIK Environment.UserName only gives the User of the Operating System on the particular machine it runs on.

(Don''t know what happened there, got cut off mid-stream)

So your program could call Environment.UserName or My.User.Name and send that information to the database where it could store the Machine Name, User Name and Time.

(This is really odd 2nd time)
Then in the OnFormClosing event handler call it again and send that to the server where the logout time can be stored.

There is probably a better solution than this but this should work.


这篇关于确定谁连接到应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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