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;
}