如何在C#控制台应用程序中获取用户的userid / windows emailid [英] How to get userid/windows emailid of user in C# console application

查看:407
本文介绍了如何在C#控制台应用程序中获取用户的userid / windows emailid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在c#中创建一个控制台应用程序。我的要求是获取登录用户的UserID或电子邮件ID(不是USERNAME)。



此应用程序将安装在不同的客户端计算机和每个客户端上机器将数据发送到服务器。我需要根据机器ID和userId来区分服务器上的数据。目前我正在获得AzureAD\FirstNameLastName。



此外,如果不使用office365会是什么情况,我的意思是代码中会有任何变化案例用户未在Office365中配置?



我尝试过:



System.Security.Principal.WindowsIdentity.GetCurrent()。名称

解决方案





看看这个答案对你有帮助吗。

c# - Save Azure Active目录用户ID - Stack Overflow



 System.IdentityModel.Claims.ClaimTypes.NameIdentifier 


I am creating a console application in c#. My requirement is to get the UserID or Email ID (NOT THE USERNAME) of the logged in user.

This application will be installed on the different client machine and each client machine will send to data to server. I need to distinguish the data on the server on the basis of machine id and userId. Currently I am getting "AzureAD\FirstNameLastName".

Also, what will be the case if office365 is not used, I mean will there be any change in code in case user is not configured in Office365?

What I have tried:

System.Security.Principal.WindowsIdentity.GetCurrent().Name

解决方案

Hi,

See if this answer help you.
c# - Save Azure Active Directory user id - Stack Overflow.

System.IdentityModel.Claims.ClaimTypes.NameIdentifier


这篇关于如何在C#控制台应用程序中获取用户的userid / windows emailid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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