将本地 .Net 身份迁移到 Azure ADB2C 并创建准确的用户 ID
Migrating Local .Net Identity to Azure ADB2C and Creating the Exact User Id
在下面的代码中,我在 b2c 上创建了一个用户,但是当我在 azure 门户上检查该用户时,除了 Id 之外的所有字段都是正确的,我怎样才能让 azure b2c 创建一个具有确切用户 id 的相同用户?
private static async Task MigrateUserAsync(GraphServiceClient client, MigratedUser user, string b2cDomainName)
{
var userPrincipalName = $"cpim_{Guid.NewGuid()}@{b2cDomainName}";
await client.Users.Request().AddAsync(new User
{
AccountEnabled = true,
Id = "837b0857-11cb-46ad-a229-4cd8de66d033",
DisplayName = user.DisplayName,
GivenName = user.GivenName,
Surname = user.Surname,
Identities = new List<ObjectIdentity>
{
new ObjectIdentity
{
SignInType = "emailAddress",
Issuer = b2cDomainName,
IssuerAssignedId = user.Email
},
},
PasswordProfile = new PasswordProfile
{
Password="xXx111!!!",
ForceChangePasswordNextSignIn=false
},
PasswordPolicies = "DisablePasswordExpiration",
});
}
创建的用户与我在创建用户时指定的 ID 不同。我找不到解决此问题的任何文档。
id,objectId,是在目录下创建用户时随机生成的。您不能提供 objectId。
您可以改为将另一个身份添加到身份集合中以存储旧 ID。这将提供一种查找具有旧 ID 的帐户的方法。
new ObjectIdentity
{
SignInType = "oldId",
Issuer = "legacyIdp.com",
IssuerAssignedId = "<GUID>"
},
在下面的代码中,我在 b2c 上创建了一个用户,但是当我在 azure 门户上检查该用户时,除了 Id 之外的所有字段都是正确的,我怎样才能让 azure b2c 创建一个具有确切用户 id 的相同用户?
private static async Task MigrateUserAsync(GraphServiceClient client, MigratedUser user, string b2cDomainName)
{
var userPrincipalName = $"cpim_{Guid.NewGuid()}@{b2cDomainName}";
await client.Users.Request().AddAsync(new User
{
AccountEnabled = true,
Id = "837b0857-11cb-46ad-a229-4cd8de66d033",
DisplayName = user.DisplayName,
GivenName = user.GivenName,
Surname = user.Surname,
Identities = new List<ObjectIdentity>
{
new ObjectIdentity
{
SignInType = "emailAddress",
Issuer = b2cDomainName,
IssuerAssignedId = user.Email
},
},
PasswordProfile = new PasswordProfile
{
Password="xXx111!!!",
ForceChangePasswordNextSignIn=false
},
PasswordPolicies = "DisablePasswordExpiration",
});
}
创建的用户与我在创建用户时指定的 ID 不同。我找不到解决此问题的任何文档。
id,objectId,是在目录下创建用户时随机生成的。您不能提供 objectId。
您可以改为将另一个身份添加到身份集合中以存储旧 ID。这将提供一种查找具有旧 ID 的帐户的方法。
new ObjectIdentity
{
SignInType = "oldId",
Issuer = "legacyIdp.com",
IssuerAssignedId = "<GUID>"
},