From d59b7d44008209d82b7a509d4d882cd74d64a788 Mon Sep 17 00:00:00 2001 From: Yasasr1 Date: Tue, 7 May 2024 11:07:57 +0530 Subject: [PATCH] Resolve user ID from username. --- .../scim2/common/impl/SCIMRoleManagerV2.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMRoleManagerV2.java b/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMRoleManagerV2.java index b823e739b..c2e556f64 100644 --- a/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMRoleManagerV2.java +++ b/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMRoleManagerV2.java @@ -1297,10 +1297,19 @@ private void prepareAddedRemovedUserLists(Set addedMembers, Set ResponseCodeConstants.INVALID_VALUE); } + String userID = memberObject.get(SCIMConstants.RoleSchemaConstants.VALUE); + if (StringUtils.isEmpty(userID)) { + userID = userStoreManager.getUserIDFromUserName( + memberObject.get(SCIMConstants.RoleSchemaConstants.DISPLAY)); + if (StringUtils.isEmpty(userID)) { + throw new BadRequestException("User can't be resolved from the given username.", + ResponseCodeConstants.NO_TARGET); + } + } + List roleList; try { - roleList = roleManagementService.getRoleIdListOfUser( - memberObject.get(SCIMConstants.RoleSchemaConstants.VALUE), tenantDomain); + roleList = roleManagementService.getRoleIdListOfUser(userID, tenantDomain); } catch (IdentityRoleManagementException e) { throw new CharonException("Error occurred while retrieving the role list of user."); }