factored code to RetrieveUserGroups in preparation for async

Signed-off-by: abbr <wenfred@gmail.com>