Hi Jose,
Thanks for confirming and the response. Find below details of my last query.
I have a need to add my own custom attributes to user schema.
I followed the steps to add custom attributes as described here:
https://gluu.org/docs/ce/3.1.1/admin-guide/attribute/
I'm using SCIM-Client Java library version 3.1.1.Final
for scim interactions.
Code snippet to add custom attribute:
```
gluu.scim2.client.ScimClient.createUser(createDummyUser(), new String[] {});
......
private User createDummyUser() throws Exception {
final User user = new User();
final Name name = new Name();
name.setGivenName("Darth Vader");
name.setFamilyName("Vader");
user.setName(name);
user.setDisplayName(String.format("TestUser_DisplayName_%d", System.currentTimeMillis()));
user.setActive(true);
user.setUserName("Darth Vader_" + new Date().getTime());
user.setPassword("starwars");
final List<Email> emails = new ArrayList<>();
Email email = new Email();
email.setPrimary(true);
email.setValue("darthvader@starwars.com");
emails.add(email);
user.setEmails(emails);
try {
Extension.Builder extensionBuilder = new Extension.Builder(Constants.USER_EXT_SCHEMA_ID);
extensionBuilder.setField("scimCustomAccountId","1");
user.addExtension(extensionBuilder.build());
} catch (Exception e) {
e.printStackTrace();
}
return user;
}
```
The user gets added successfully with custom attribute. No issues in adding user.I can see the value in admin console.
But,when I'm retrieving or searching the user, I'm not able to read this custom attribute.
Here is the code to search user based on username.
```
public List<User> searchUsers(String aUserName) {
List<User> users = Collections.emptyList();
final ScimClient scimClient = getScimClient();
final String filter = "userName eq \"" + aUserName + "\"";
int startIndex = 1;
int count = 1;
final String sortBy = "";
final String sortOrder = "";
final String[] attributes = null;
try {
final BaseClientResponse<ListResponse> response = scimClient.searchUsers(filter, startIndex, count, sortBy,
sortOrder, attributes);
if (response.getStatus() == 200) {
ListResponse listResponse = response.getEntity();
users = listResponse.getResources().stream().filter(User.class::isInstance).map(User.class::cast)
.collect(Collectors.toList());
}
} catch (IOException aE) {
log.debug(aE)
}
return users;
}
```
Here is the code to read custom attribute:
```
final Extension extension = aUser.getExtension(Constants.USER_EXT_SCHEMA_ID);
final Extension.Field accountIdFiled = extension.getFields().get("scimCustomAccountId");
final String accountId = accountIdFiled.getValue();
```
I'm getting below exception
```
java.util.NoSuchElementException: extension urn:ietf:params:scim:schemas:extension:gluu:2.0:User is not available
at org.gluu.oxtrust.model.scim2.User.getExtension(User.java:449)
```
I did check that the attribute is part of the User Extension by verify it here:
https://<host-name>/identity/restv1/scim/v2/Schemas/urn:ietf:params:scim:schemas:extension:gluu:2.0:User
```
{
"id": "urn:ietf:params:scim:schemas:extension:gluu:2.0:User",
"externalId": null,
"meta": {
"created": null,
"lastModified": null,
"location": "https://www.imcidp.com/identity/restv1/scim/v2/Schemas/urn:ietf:params:scim:schemas:extension:gluu:2.0:User",
"version": null,
"resourceType": "Schema"
},
"name": "GluuUserCustomExtension",
"description": "Gluu User Custom Extension",
"attributes": [
{
"name": "oxEnrollmentCode",
"type": "string",
"description": "oxEnrollmentCode",
"required": false,
"multiValued": false,
"caseExact": false,
"mutability": "readWrite",
"returned": "default",
"uniqueness": "none",
"subAttributes": [],
"referenceTypes": []
},
{
"name": "scimCustomAccountId",
"type": "string",
"description": "Custom user account Id",
"required": false,
"multiValued": false,
"caseExact": false,
"mutability": "readWrite",
"returned": "default",
"uniqueness": "none",
"subAttributes": [],
"referenceTypes": []
}
]
}
```
Let me know if you need more information.
Thanks again for your guidance.