Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 11-Jul-17 2:29am
v2

1 solution

Hi,

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

C#
System.IdentityModel.Claims.ClaimTypes.NameIdentifier
 
Share this answer
 
Comments
tewary_manish 11-Jul-17 9:15am    
@Sheila Pontes : No, it didn't helped.
Sheila Pontes 11-Jul-17 9:59am    
What is this user id that you do want? You said that you don't want the username, but the username is unique key in windows.
I found a post on how to get a unique ID from a logged-in user in the Windows session. Id changes every session. Is this?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900