diff --git a/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/utils/SCIMCommonUtils.java b/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/utils/SCIMCommonUtils.java index 4dd1f403..0db6f902 100644 --- a/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/utils/SCIMCommonUtils.java +++ b/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/utils/SCIMCommonUtils.java @@ -925,6 +925,9 @@ public static void updateSystemRoleV2MetaData(int tenantId) { */ public static String getLoggedInUserID() throws CharonException { + if (PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserId() != null) { + return PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserId(); + } try { String loggedInUserName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); String loggedInUserTenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();