Search code examples
azureazure-active-directoryadaladal.js

How to pass user information back to server side with ADAL for angular


I am trying to integrate azure Active Directory Authentication Library for js to my site. I downloaded the SPA sample and made it work with my app detail.

However, how can I pass user information back to server?

For example, this is the example code on server side to retrive the logged in user:

string owner = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;
IEnumerable<Todo> currentUserToDos = db.Todoes.Where(a => a.Owner == owner);

The owner string turned out to be a guid like token other than a readable username or email address.

Is there a way to retrieve username or email address by using this library directly or I have to send it to server side myself?


Solution

  • ClaimTypes.NameIdentifier is a guid unique to each user. If you want readable username or email address, try ClaimTypes.Email or ClaimTypes.Name.