Error on create a user with MS Graph REST API V1.0 ?

Mohamed Rikas 6 Reputation points
2021-07-06T15:33:17.207+00:00

Already given these permissions.

User.ReadWrite.All, Directory.ReadWrite.All , Directory.AccessAsUser.All

My User is as per this.

        var newUserWithMultippleIdentity = new User
        {
            DisplayName = "Riki Joe",

            Identities = new List<ObjectIdentity>()
            {
                new ObjectIdentity
                {
                    SignInType = "userName",
                    Issuer = "btrikas.onmicrosoft.com",
                    IssuerAssignedId = "johnsmith"
                },
                new ObjectIdentity
                {
                    SignInType = "emailAddress",
                   Issuer = "btrikas.onmicrosoft.com",
                   IssuerAssignedId = "******@gmail.com"
                },
            },
            PasswordProfile = new PasswordProfile
            {
                Password = "xWwvJ]6NMw+bWH-d",
                ForceChangePasswordNextSignIn = false,
            },
            PasswordPolicies = "DisablePasswordExpiration"
        };

var graphServiceClnt = _startup.CreateTenant(tenant, scopesUserCreate);
var secureStringPassword = _helper.getSecureString("", password);

        User newUser = await graphServiceClnt.Users
            .Request()
            .AddAsync(user);

I tried with this user but it was asking me to give values to following properties too.

            AccountEnabled = true,
            MailNickname = "RikiJo",
            CreationType = "LocalAccount",
            UserPrincipalName = "******@btrikas.onmicrosoft.com",

still the error comes saying "Some properties are missing" but not mentioned specifically what's missing.

Did as per documentation but nothing works ? please help me.

Microsoft Security | Microsoft Graph
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Mohamed Rikas 6 Reputation points
    2021-07-06T17:16:41.827+00:00

    112258-msft-graph.png

    Here is my request on Microsoft graph explorer , same input same error.


  2. CarlZhao-MSFT 46,376 Reputation points
    2021-07-13T09:45:13.423+00:00

    After many tests, I reproduced and solved your problem. The problem appears on the issuer attribute. Since you are creating a local Azure AD B2C user, please note that this is not an Azure AD user, so you must log in with the administrator account of the Azure ad b2c tenant to graph explorer, and then you need to set the issuer to the domain of the Azure ad b2c tenant.

    114190-219.png

    code:

    GraphServiceClient graphClient = new GraphServiceClient( authProvider );  
      
    var user = new User  
    {  
      DisplayName = "{displayName}",  
      CreationType = "LocalAccount",  
      Identities = new List<ObjectIdentity>()  
       {  
        new ObjectIdentity  
       {  
     SignInType = "userName",  
     Issuer = "{azure ad b2c tenant domain}",  
     IssuerAssignedId = "johnsmithtest1"  
       }  
     },  
      PasswordProfile = new PasswordProfile  
       {  
         Password = "{Password}",  
         ForceChangePasswordNextSignIn = false  
       },  
      PasswordPolicies = "DisablePasswordExpiration"  
    };  
      
    await graphClient.Users  
     .Request()  
     .AddAsync(user);  
    

    If an Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.