SHARE:

SignInNames available in Microsoft Graph

Introduction

If you were using https://graph.microsoft.com/ you have probably noticed that it was not possible to create a User in Azure AD B2C with a custom signInName unlike the older Graph API (https://graph.windows.net/).

Good news!

That feature is available in the new beta release ! (https://graph.microsoft.com/beta/)

Let’s see how we can migrate to the new beta release!

Note: In this demo I won’t use any SDK, I will build queries with an HttpClient in which I set a JObject serialized to a JSON string with C#.

Migration scenario

I wanted (and I still want to) to log in in Azure B2C with my personal Gmail address, the payload was looking like this:

Data model returned from Graph API looks like this (I built my own model instead of using any SDK):

Now let’s see what the new Microsoft Graph user payload looks like:

Models, especially “signInNames” are now named “identities” and “creationType” property has disappeared.

A new property has been added: “issuerAssignedId” (has implicitly made “creationType” property obsolete) and this is the value of your custom signInName. You have to set your “issuer” property even if you are using a custom email address like Gmail.

CRUD operation with ADAL.NET

Here is a service that contains a bunch of services to manipulate User entity with Microsoft Graph (beta):

I wrote a custom client to manage operations like create, get user by userId, get user by SignInName, update user (update SignInName) and delete a user (disable). That client utilizes ADAL.NET and it works pretty well with Microsoft Graph as well as Graph API.

Microsoft Graph allows you to use both ADAL.NET and MSAL.NET and even a SDK to build shortcuts on your Microsoft Graph client.

In the next article I will show you how to rewrite to client with MSAL.NET and the SDK.

Written by

anthonygiretti

Anthony is a specialist in Web technologies (14 years of experience), in particular Microsoft .NET and learns the Cloud Azure platform. He has received twice the Microsoft MVP award and he is also certified Microsoft MCSD and Azure Fundamentals.
%d bloggers like this: