diff --git a/components/org.wso2.carbon.identity.api.user.organization/org.wso2.carbon.identity.rest.api.user.organization.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/organization/v1/core/UserOrganizationService.java b/components/org.wso2.carbon.identity.api.user.organization/org.wso2.carbon.identity.rest.api.user.organization.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/organization/v1/core/UserOrganizationService.java index b46873e21..02df42da9 100644 --- a/components/org.wso2.carbon.identity.api.user.organization/org.wso2.carbon.identity.rest.api.user.organization.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/organization/v1/core/UserOrganizationService.java +++ b/components/org.wso2.carbon.identity.api.user.organization/org.wso2.carbon.identity.rest.api.user.organization.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/organization/v1/core/UserOrganizationService.java @@ -55,6 +55,7 @@ import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.SUPER_ORG_ID; import static org.wso2.carbon.identity.organization.management.service.util.Utils.buildURIForBody; import static org.wso2.carbon.identity.organization.management.service.util.Utils.getOrganizationId; +import static org.wso2.carbon.identity.organization.management.service.util.Utils.getTenantDomain; import static org.wso2.carbon.identity.rest.api.user.organization.v1.Constants.ASC_SORT_ORDER; import static org.wso2.carbon.identity.rest.api.user.organization.v1.Constants.DESC_SORT_ORDER; import static org.wso2.carbon.identity.rest.api.user.organization.v1.Constants.ORGANIZATIONS_ME_ENDPOINT; @@ -103,10 +104,10 @@ public List getUserOrganizationHierarchyUptoResidentOrg String userId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserId(); String accessedOrgId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getOrganizationId(); - if (StringUtils.isBlank(accessedOrgId)) { - accessedOrgId = SUPER_ORG_ID; - } try { + if (StringUtils.isBlank(accessedOrgId)) { + accessedOrgId = getOrganizationManagementService().resolveOrganizationId(getTenantDomain());; + } List rootDescendantsOrganizationResponseList = new ArrayList<>(); List basicOrganizationList = getOrganizationUserResidentResolverService() .getHierarchyUptoResidentOrganization(userId, accessedOrgId);