gpt4 book ai didi

microsoft-graph-api - 使用图形 API 将用户添加到 Azure B2C 时允许所有域

转载 作者:行者123 更新时间:2023-12-03 16:32:17 27 4
gpt4 key购买 nike

我正在尝试使用电子邮件 ...@gmail.com 添加用户通过 Graph API (C#) 到我的 B2C 目录。我得到这个作为回应:

The domain portion of the userPrincipalName property is invalid. Youmust use one of the verified domain names in your organization.


该系统需要允许任何电子邮件域的用户登录。用户需要登录网站,不能访问 Azure 门户。
有没有办法在不手动添加每个域的情况下完成此操作?
通过Graph API添加用户的代码:
var confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(clientId)
.WithTenantId(tenantId)
.WithClientSecret(clientSecret)
.Build();

var authProvider = new ClientCredentialProvider(confidentialClientApplication);

var graphClient = new GraphServiceClient(authProvider);

var user = new User
{
AccountEnabled = true,
DisplayName = emailAddress,
MailNickname = emailAddress.Split('@').FirstOrDefault(),
UserPrincipalName = emailAddress,
PasswordProfile = new PasswordProfile
{
ForceChangePasswordNextSignIn = true,
Password = tempPassword
}
};

最佳答案

如果您尝试创建本地 B2C(而非 AAD)帐户,请尝试设置 identities您的请求中的属性,但不是 upn。这最后应该是自动生成的。此外,必须禁用密码过期,并且还必须禁用下次登录时强制更改密码。

关于microsoft-graph-api - 使用图形 API 将用户添加到 Azure B2C 时允许所有域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64860449/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com