从扩展中获取登录的 Visual Studio 用户的身份 [英] Get identity of logged in Visual Studio user from extension

查看:20
本文介绍了从扩展中获取登录的 Visual Studio 用户的身份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 Visual Studio 2015 扩展,我希望获得登录到 IDE 的用户的身份(不同于登录到 Windows 或运行 devenv 的用户).

我不知道在哪里(或是否)可以获取该信息.它似乎不在

I'm developing a visual studio 2015 extension and I'm looking to get the identity of the user who's logged into the IDE (different to the user logged in to windows, or running devenv).

I can't figure out where (or if) I can get that information. It doesn't appear to be in the DTE object anywhere and googling around hasn't helped.

解决方案

Just the username

string username = System.Environment.UserName;

or

string adName = System.Environment.UserDomainName;

Full UserPrinciple

System.DirectoryServices.AccountManagement.UserPrincipal.Current

Most the normal .net methods for getting users from system or globals should work. All the AD namespaces (System.DirectoryServices) will also work as usual.

Also this regkey gets set at vs startup with the interactive user.

这篇关于从扩展中获取登录的 Visual Studio 用户的身份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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