Skip to content

Instantly share code, notes, and snippets.

@chelnak
Created October 4, 2016 10:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelnak/1267acd42373f852ee64eae5fe12e3a4 to your computer and use it in GitHub Desktop.
Save chelnak/1267acd42373f852ee64eae5fe12e3a4 to your computer and use it in GitHub Desktop.
Retrieve the Email Address of a user principal in vRA with vRO
/*
- Retrieve the email address of a user principal
- Input: vCACCAFEHost [vCACCAFE:vCACHost]
- Input: principalId [String]
- Output: emailAddress [String]
*/
var tenant = vCACCAFEHost.tenant;
var authenticationClient = vCACCAFEHost.createAuthenticationClient();
var authenticationPrincipalService = authenticationClient.getAuthenticationPrincipalService();
try {
var principal = authenticationPrincipalService.getPrincipal(tenant,principalId);
//Principal is a vCACCAFEUser object
var emailAddress = principal.getEmailAddress();
} catch (e) {
throw "Could not find principal " + principalId + ". " + e;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment