Created
October 4, 2016 12:56
-
-
Save chelnak/2a3d3c5ffa1e4a9b5d67fe04a3cb078d to your computer and use it in GitHub Desktop.
Reset the password of a vRA local user principal with vRO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
- Reset the password of a local user principal | |
- Input: vCACCAFEHost [vCACCAFE:vCACHost] | |
- Input: principalId [String] | |
- Input: password [SecureString] | |
- Input: confirmPassword [SecureString] | |
- Output: [Void] | |
*/ | |
var tenant = vCACCAFEHost.tenant; | |
var authenticationClient = vCACCAFEHost.createAuthenticationClient(); | |
var authenticationPrincipalService = authenticationClient.getAuthenticationPrincipalService(); | |
try { | |
//Get the principal | |
var principal = authenticationPrincipalService.getPrincipal(tenant,principalId); | |
//Simple confirmation that both passwords match | |
if (password != confirmPassword) { | |
throw "Passwords do not match"; | |
} | |
//Set the password on the vCACCAFEUser object | |
principal.setPassword(password); | |
//Update the principal | |
System.log("Setting password for " + principalId); | |
authenticationPrincipalService.updateLocalUser(principal); | |
System.log("Success"); | |
} catch (e) { | |
throw "An error occured when updating principal: " +e; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment