In an ASP.NET
Web API, I need to be able to identify users with a unique id so I can refer to them in another DB. All users are on Azure Active Directory
. I don't want something that can change over time (like a SID).
I tried getting the user Guid with a Membership
like this, but I found that Azure Active Directory does not support Memberships.
I found IdentityExtensions.GetUserId() that is used like this: User.Identity.GetUserId()
. The id generated seems to be neither the Guid or the SID. However, it seems to be unique to each user.
Can User.Identity.GetUserId()
be used to uniquely identify AAD users? If not, what is the right way to do it?