diff --git a/components/org.wso2.carbon.identity.authz.valve/src/main/java/org/wso2/carbon/identity/authz/valve/AuthorizationValve.java b/components/org.wso2.carbon.identity.authz.valve/src/main/java/org/wso2/carbon/identity/authz/valve/AuthorizationValve.java index ebb762e0..d16875a9 100644 --- a/components/org.wso2.carbon.identity.authz.valve/src/main/java/org/wso2/carbon/identity/authz/valve/AuthorizationValve.java +++ b/components/org.wso2.carbon.identity.authz.valve/src/main/java/org/wso2/carbon/identity/authz/valve/AuthorizationValve.java @@ -300,12 +300,16 @@ private boolean isAuthorizationSkipped(String authHandlerName, String requestUri private void startOrganizationBoundTenantFlow(String authorizedOrganization) { + String userId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserId(); + String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setOrganizationId(authorizedOrganization); try { String authorizedTenantDomain = AuthorizationValveServiceHolder.getInstance().getOrganizationManager() .resolveTenantDomain(authorizedOrganization); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(authorizedTenantDomain, true); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setUserId(userId); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(userName); } catch (OrganizationManagementException e) { throw new AuthRuntimeException("Error while resolving tenant domain by organization.", e); }