在 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"