Get identity of logged in Visual Studio user from extension

╄→гoц情女王★ 提交于 2019-12-07 07:37:39

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!