MJ X
MJ X

Reputation: 9054

Creating new user in Azure AD b2c error: Another object with the same value for property proxyAddresses already exists

I have a program which I create users through Microsoft graph in my Azure AD b2c for normal users the code runs and creates AD b2c account

In the B2C I have admin users which are the Tenant administrators When I try to create programatically accounts for the same user as b2c user I get error

Creating new user in Azure AD b2c error: Another object with the same value for property proxyAddresses already exists

but when I perform the same operation through GUI I can add 2 accounts with the same email. the first is the user which is invited as admin and the second is the B2C normal user

                            var user = new User
                            {
                                AccountEnabled = true,

                                GivenName = "MJX",
                                Surname = MJX,
                                Mail = theEmail,
                                DisplayName = "Someting",
                                UserType = "Member",
                                CreationType = "LocalAccount",
                                PasswordProfile = new PasswordProfile
                                {
                                    ForceChangePasswordNextSignIn = true,
                                    Password = GeneratedPassword,
                                },
                                PasswordPolicies = "DisablePasswordExpiration",
                                Identities = new List<ObjectIdentity>
                            {
                                new ObjectIdentity()
                                {
                                    SignInType = "emailAddress",
                                    Issuer = tenantName,
                                    IssuerAssignedId = theEmail
                                }
                            }
                            };

                            //insert into AD
                            var createdUser = graphServiceClient.Users
                                .Request()
                                .AddAsync(user).GetAwaiter().GetResult();

Upvotes: 1

Views: 1001

Answers (1)

MJ X
MJ X

Reputation: 9054

Removed the Mail property it worked for me

 //Mail = theEmail

Upvotes: 2

Related Questions