Pivotal Cloud Foundry® (PCF) 1.5.x, 1.6.x, and 1.7.x
When a user is trying to set a space-role using,
cf set-space-role they get the following error:
Server error, error code: 1002, message: cannot set space role because user is not part of the org
This happens because the admin user is trying to set a space-role for a specific user without setting an org-role. For the user to belong to particular space (by getting a space-role), the user must be part of the organizations (that space resides in) first (by getting an org-role).
Resolving this issue is quite easy. Simply issue the following command:
$ cf set-org-role USERNAME ORG (OrgManager/BillingManager/OrgAuditor)
After the user has an org-role set for them, any org or space admin should be able to use the
cf set-space-role to set a space-role for the user.