Filter query for Graph B2C for mixed case IssuerAssignedId

Viewed 536

In our Azure B2C we let users to sign up using mixed-case emails as their logins (IssuerAssignedId). Now we have a lot of users (not all but many) with IssuerAssignedId like Name.Surname@domain.com.

In our API we have endpoints that perform business validation of the user by given email, and API clients provide these emails in all lowercase. So Graph API call fails to find user when email is given like name.surname@domain.com if actually registered B2C IssuerAssignedId is Name.Surname@domain.com.

We use standard filter syntax:

await _graphServiceClient.Users
  .Request()
  .Filter($"identities/any(c: c/issuerAssignedId eq '{email}' and c/issuer eq '{issuer}')")
  .Select(e => new { e.DisplayName, e.Id, e.Identities})
  .GetAsync();

The problem is that filter query does not allow to use tolower() odata function like

$"identities/any(c: tolower(c/issuerAssignedId) eq '{email}' and c/issuer eq '{issuer}')"

so I'm unable to normalize the email from lambda argument. As I understand, odata for Graph B2C has some limitations comparing to standard.

What can be the approach to resolve such issue?

1 Answers

If you use Graph API to create user records, you can assign the lower case version of the IssuerAssignedId to mail or an extension attribute. You can then use that for lower case searching.

For existing data, you can fill in the lower case value to the new column by Graph API PATCH call.

Related