如何获得当前登录的用户名和账户类型(管理员,非管理员),当应用程序被运行方式目前存在的用户 [英] How to get Currently Logged on User Name and Account Type(admin,nonadmin) When the application is Run As differnet User
本文介绍了如何获得当前登录的用户名和账户类型(管理员,非管理员),当应用程序被运行方式目前存在的用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 C#
如何获得当前登录的Windows用户,如果应用程序是由不同的充用户使用为
?
In C#
How to get the currently logged on windows user if the application is executed by differnt user using Run as
?
WindowsIdentity.GetCurrent();
总是给人为
运行用户或模拟用户。我只是想在Windows登录用户名和用户帐户类型。
WindowsIdentity.GetCurrent();
always gives the Run as
user or impersonated user. I just want the windows logged on user name and user account type.
推荐答案
尝试使用WMI来获得登录用户的会话: 从Win32_LogonSession *如果LogonType = 2
Try to use WMI to get logon user sessions: "Select * from Win32_LogonSession Where LogonType = 2"
这篇关于如何获得当前登录的用户名和账户类型(管理员,非管理员),当应用程序被运行方式目前存在的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文