question

MohamedRikas-5458 avatar image
1 Vote"
MohamedRikas-5458 asked CarlZhao-MSFT commented

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

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 = "mohamedrks@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 = "rj@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-graph-users
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MohamedRikas-5458 avatar image
0 Votes"
MohamedRikas-5458 answered CarlZhao-MSFT commented

112258-msft-graph.png




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


msft-graph.png (120.8 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

This is not a canonical answer. Can you delete this answer?

0 Votes 0 ·
CarlZhao-MSFT avatar image
0 Votes"
CarlZhao-MSFT answered CarlZhao-MSFT edited

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.








219.png (105.0 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.