英文:
move bulk users upload from local db to azure b2c active directory in JAVA
问题
我正在尝试创建一个 Java 控制台应用程序,通过该应用程序,我想将超过 100,000 个用户迁移到 Azure AD B2C。
我们将使用 Graph API 来实现此目的。
我已经创建了一个 JSON 格式的文件,其中包含用户列表,格式如下:
{
"users": [
{
"displayName": "Amanda Polly",
"givenName": "Amanda",
"surname": "Polly",
"extension_user_type": "user",
"identities": [
{
"signInType": "emailAddress",
"issuerAssignedId": "amandapolly@gmail.com"
}
],
"extension_timezone": "PST",
"extension_locale": "en-US",
"extension_tenant": "EG1234"
},
{
"displayName": "Lowa Doe",
"givenName": "Lowa",
"surname": "Doe",
"extension_user_type": "user",
"identities": [
{
"signInType": "userName",
"issuerAssignedId": "lowadow123"
}
],
"extension_timezone": "PST",
"extension_locale": "en-US",
"extension_tenant": "EG1234"
}
]
}
我将这个内容保存在一个(dot)json文件中,我需要使用这个文件,并使用 Graph API 在 B2C 活动目录中创建用户。在开始时需要帮助。
英文:
I am trying to make a console app in java through which I want to migrate more than 100000 users to Azure AD B2C.
We are using Graph API for this purpose.
I have created a JSON format file which has a list of users, looks like below :
{
"users": [
{
"displayName": "Amanda Polly",
"givenName": "Amanda",
"surname": "Polly",
"extension_user_type": "user",
"identities": [
{
"signInType": "emailAddress",
"issuerAssignedId": "amandapolly@gmail.com"
}
],
"extension_timezone": "PST",
"extension_locale": "en-US",
"extension_tenant": "EG1234"
},
{
"displayName": "Lowa Doe",
"givenName": "Lowa",
"surname": "Doe",
"extension_user_type": "user",
"identities": [
{
"signInType": "userName",
"issuerAssignedId": "lowadow123"
}
],
"extension_timezone": "PST",
"extension_locale": "en-US",
"extension_tenant": "EG1234"
}
]
}
I have this in a (dot)json file, i have to use this file and create users in b2c active directory using graph API, need help in starting.
答案1
得分: 1
以下是翻译好的部分:
用户图形 API 并发送一个 POST 请求,就像这样:
设置所有字段,然后像这样处理它。
User createNewUser = new User();
createNewUser.displayName = displayName;
if (givenName.equals(null) || givenName.isEmpty() || givenName.equals("") || givenName.equals(" ")) {
LOG.warn("givenName is empty");
} else {
createNewUser.givenName = givenName;
}
if (surname.equals(null) || surname.isEmpty() || surname.equals("") || surname.equals(" ")) {
LOG.warn("surname is empty");
} else {
createNewUser.surname = surname;
}
final LinkedList<ObjectIdentity> identitiesList = new LinkedList<ObjectIdentity>();
ObjectIdentity identities = new ObjectIdentity();
identities.signInType = signInType;
identities.issuerAssignedId = issuerAssignedId;
identities.issuer = "controlme.onmicrosoft.com";
identitiesList.add(identities);
createNewUser.identities = identitiesList;
PasswordProfile passwordProfile = new PasswordProfile();
passwordProfile.password = generatePassword(15);
passwordProfile.forceChangePasswordNextSignIn = false;
createNewUser.passwordProfile = passwordProfile;
createNewUser.passwordPolicies = "DisablePasswordExpiration";
User buildUserRequest = graphClient.users()
.buildRequest()
.post(createNewUser);
英文:
User graph api and send a post request, like this
Set all the fields and then work it out like this.
User createNewUser = new User();
createNewUser.displayName = displayName;
if (givenName.equals(null) || givenName.isEmpty() || givenName.equals("") || givenName.equals(" ")) {
LOG.warn("givenName is empty");
} else {
createNewUser.givenName = givenName;
}
if (surname.equals(null) || surname.isEmpty() || surname.equals("") || surname.equals(" ")) {
LOG.warn("surname is empty");
} else {
createNewUser.surname = surname;
}
final LinkedList<ObjectIdentity> identitiesList = new LinkedList<ObjectIdentity>();
ObjectIdentity identities = new ObjectIdentity();
identities.signInType = signInType;
identities.issuerAssignedId = issuerAssignedId;
identities.issuer = "controlme.onmicrosoft.com";
identitiesList.add(identities);
createNewUser.identities = identitiesList;
PasswordProfile passwordProfile = new PasswordProfile();
passwordProfile.password = generatePassword(15);
passwordProfile.forceChangePasswordNextSignIn = false;
createNewUser.passwordProfile = passwordProfile;
createNewUser.passwordPolicies = "DisablePasswordExpiration";
User buildUserRequest = graphClient.users()
.buildRequest()
.post(createNewUser);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论