Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 22514

Get the Entra (AzureAD) Login name from a WinForm Application

$
0
0

I have written a Windows Task Tray Application using WinForms. This works fine. This application is a local agent for a SaaS offering. For licensing purposes, I want to be able to match the logged in user to the SaaS subscribers' users. This is where the trouble starts. Users log into their desktop Windows PC using their Entra ID, which is in the form of "firstname.lastname@subscriberdomain.ext". In the Task tray application, I use the Environment.UserName and Environment.UserDomainName which give firstnamelastname and "AzureAD" respectively.

Users are known in the SaaS by their Entra login "firstname.lastname@subscriberdomain.ext", so I need to go from the local representation to the SaaS value for usage tracking. My task tray application agent does not require a separate login since the user is logged into Windows desktop and I want to keep it that way. The Task Tray authenticates to the SaaS using cert based authentication. I would prefer not to call Graph from the task tray as that may require an additional authentication. Is there any way to go from the local representation of logged-in user,domain to Entra login name representation?

I have tried a lot of different things, including: System.Security.Principal.WindowsIdentity.GetCurrent().Name; System.DirectoryServices.AccountManagement.UserPrincipal.Current.DisplayName; Reading the registry and have not been able to find a suitable solution. AD solutions don't work since it is AzureAd. I have tried to convert from a SID to an OID.


Viewing all articles
Browse latest Browse all 22514

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>