在Azure AD B2C中创建新用户错误:已存在具有相同值相同值的另一个对象已经存在

发布于 2025-02-10 20:34:52 字数 1898 浏览 1 评论 0原文

我有一个程序,通过我的Azure AD B2C中的Microsoft Graph创建用户 对于普通用户,代码

在B2C中运行并创建AD B2C帐户,我拥有管理员的管理员 当我尝试以与B2C用户相同的用户为单位的程序上创建错误时,我会收到错误,

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

但是当我通过GUI执行相同的操作时,我可以使用同一电子邮件添加2个帐户。 第一个是被邀请作为管理员的用户,第二个是B2C普通用户

                            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();

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();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

极致的悲 2025-02-17 20:34:52

删除了它为我工作的邮件属性

 //Mail = theEmail

Removed the Mail property it worked for me

 //Mail = theEmail
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文