简体   繁体   中英

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).

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. 在此处输入图片说明

Code: C#

General: in header / above namespace MVC: Not sure about earlier version but 3 - 5 not required

using System.Security.Principal

function, property etc

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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