Forum Discussion
Retrieving Entra ID email address from macOS devices in system context
Dear Team,
We are working on retrieving email address of the user joined to Entra ID from Entra-joined macOS devices, specifically while running in a system context. The sudo dscl . -read /Users/$(whoami) RecordName command give the local user name whose password is synced with the entra ID. We would greatly appreciate guidance on how to retrieve the Entra ID joined user’s email address in a system context from Entra Joined mac devices, especially from those with prior experience in this area.
Thank you for your support.
2 Replies
hi moinkhanengr On macOS Entra-joined devices, there’s no direct system-context command to pull the user’s Entra email. A few workarounds:
Enterprise SSO plug-in → parse the cached token (JWT) to read the preferred_username (email).
Intune / Graph API → pull the “Primary User” UPN from the device record instead of locally.
Login script workaround → capture the UPN at user sign-in and store it (e.g., /var/tmp/entra_upn.txt) for later system use.
For immediate needs, the login-script approach is the most reliable.
hi moinkhanengr kindly close the thread if you are not looking for further info. thank you