How to get the original On-Prem AD account into Azure AD & SharePoint Online?

New Contributor


We have OnPrem AD where our users accounts are i.e.  Domain\ABC123  then, We got Azure AD, ADFS, and O365 where our users now use to connect and use SharePoint Online.


However, We now have a requirement in some custom solution in SharePoint Online to get the original On-Prem AD account value - How to do so? I mean, If the logged user is, How can I find out what is his original On-Prem AD account value e.g. Domain\xyz987


Is there a way to do so? Or, How can I sync that value into Azure AD or SharePoint Profile?

4 Replies
Can’t see why the samaccount name is needed? The users UPN should be set and be the same in AD as in AAD

Hi Adam,


My On-Prem AD account is actually  Domain\MaLa23264 and it work perfectly fine with our internal onPrem systems including our old SharePoint 2013 on-Prem farm.


In SharePoint Online, I use the UPN (, So, They are not the same.


In specific SharePoint solution we are building, I really need to get the original On-Prem AD account which is Domain\MaLa23264 ... How?


While the SamAccountName is synced to Azure AD, it's NOT exposed in any of the admin centers or other tools. You can only consume it via the Graph:

Ok! AFAIK this must be done programmatically! Powershell can be used as well but I’m not sure that will suit your needs
Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
30 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
29 Replies