hi,
I asked a similar question before.About how to get someone's name after sign in.Someone showed me this example and worked really great.
var displayName = ((System.Security.Claims.ClaimsIdentity)User.Identity).Claims.Where(c => c.Type == "name").FirstOrDefault().Value;
It gets the name.Unfortunately,i quickly realized that,getting the name wont be enough.Some people have exact same names.I needed something unique.So i tried email instead.It always returned null.
i tried types like
1.If i read it correctly default token for email is "email"
var displayName = ((System.Security.Claims.ClaimsIdentity)User.Identity).Claims.Where(c => c.Type == "email").FirstOrDefault().Value;
returned nothing...
2.people were recommending using this query on forums.So i have tried "preferred_username
var displayName = ((System.Security.Claims.ClaimsIdentity)User.Identity).Claims.Where(c => c.Type == "preferred_username").FirstOrDefault().Value;
again returned nothing...
after these two,any type i tried returned no result except "name".
I checked the delegate settings for app in azure active directory and "sign and read profile" is checked. Couldn't find anything wrong there.What could be the reason ? I am working in a company and we have a company domain which works under office 365...