获取“真实的" Windows用户名,而不是"runas"用户名!

编程入门 行业动态 更新时间:2024-10-11 07:29:23
本文介绍了获取“真实的" 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"用户名!

本文发布于:2023-11-07 02:07:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1565269.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:用户名   而不是   真实   Windows   quot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!