获取“真实的" Windows用户名,而不是"runas"用户名! [英] Get the 'real' windows user name, not the runas one!

查看:189
本文介绍了获取“真实的" Windows用户名,而不是"runas"用户名!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好, 如果已使用runas启动该应用程序,则.NET应用程序是否可以获得当前登录的用户(用户名)? 我试过 System.Security.Principal.WindowsIdentity.GetCurrent().Name 但它返回的是"runas"用户,而不是已登录的用户. 我希望你明白我的意思! 谢谢! Larry86

Hi everyone, is it possible for a .NET application to get the currently logged on user (username) if this application has been started with runas? I tried System.Security.Principal.WindowsIdentity.GetCurrent().Name but it returned the ''runas'' user, not the logged on one. I hope you understand what I meant! Thanks! Larry86

推荐答案

是的,我尝试过,它还会返回"runas"用户.
Yeah I tried it and it also returns the ''runas'' user.


谢谢:
我认为您可以通过传递与系统信息查询相关的(WQL)来使用(WMI)来实现它.
您可以使用System.Management.ManagementObject
Thank you :
i think you can implement it using (WMI) by passing a (WQL) related to the system information queries.
you can do that using System.Management.ManagementObject


做到这一点了吗?

Have you tried System.Environment.UserName yet?

 

霍根


这篇关于获取“真实的" Windows用户名,而不是"runas"用户名!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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