Monday, August 3, 2015

Azure AD Graph API cannot access Microsoft Account

Problem 1:

User.Identity.Name is null for Microsoft users.


in Global.ascx, write following code,
 protected void Application_PostAuthenticateRequest(Object sender, EventArgs e)
            ClaimsIdentity id = ((ClaimsIdentity)User.Identity);
            Claim claim = id.FindFirst(ClaimTypes.Email);
            if (claim != null)
                string email = claim.Value;
                id.AddClaim(new Claim(ClaimTypes.Name, email));

Problem 2: ?api-version=2013-04-05 is not returning user profile which the same api works for the local users of AD.

Solution$filter=startswith(userPrincipalName, 'testemail_hotmail')

No comments:

Post a Comment