简体   繁体   English

从扩展名获取登录的Visual Studio用户的身份

[英]Get identity of logged in Visual Studio user from extension

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). 我正在开发Visual Studio 2015扩展,并希望获得登录IDE的用户的身份(与登录Windows或运行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. 它似乎没有出现在DTE对象中的任何位置,并且四处搜寻并没有帮助。

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. 从系统或全局对象获取用户的大多数常规.net方法都应该起作用。 All the AD namespaces (System.DirectoryServices) will also work as usual. 所有AD命名空间(System.DirectoryServices)也将照常工作。

Also this regkey gets set at vs startup with the interactive user. 同样,该注册表项在交互式用户启动时设置。 在此处输入图片说明

Code: C# 代码:C#

General: in header / above namespace MVC: Not sure about earlier version but 3 - 5 not required 常规:在标头中/在名称空间上方MVC:不确定较早版本,但不需要3-5

using System.Security.Principal

function, property etc 功能,属性等

string userid= User.Identity.Name.toString()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM