use of com.salesforce.soap.partner.ResetPasswordResult in project tdi-studio-se by Talend.
the class PartnerSamples method resetPasswordSample.
private void resetPasswordSample() {
if (!loggedIn) {
if (!login()) {
return;
}
}
try {
QueryResult qr = binding.query("select UserName, LastName, FirstName, Id from User");
if (qr.getSize() > 0) {
SObject[] users = qr.getRecords();
if (users != null) {
System.out.println("\nUser List: ");
for (int i = 0; i < users.length; i++) {
int printInd = i + 1;
SObject user = users[i];
System.out.println(printInd + ". " + user.get_any()[0].getValue() + " - " + user.get_any()[2].getValue() + " " + user.get_any()[1].getValue());
}
}
String idToReset = getUserInput("\nEnter user to reset: ");
if (idToReset != null) {
int userIndex = new Integer(idToReset).intValue() - 1;
String verify = getUserInput("Please verify that you want to reset the password for \n" + users[userIndex].get_any()[2] + " " + users[userIndex].get_any()[1] + "\nby entering OK.");
if (verify.equals("OK")) {
ResetPasswordResult resetPasswordResult = binding.resetPassword(users[userIndex].getId());
if (resetPasswordResult != null) {
System.out.println("\nThe password for user " + users[userIndex].get_any()[2].getValue() + " " + users[userIndex].get_any()[1].getValue() + " has been reset to " + resetPasswordResult.getPassword());
getUserInput("\nHit enter to continue...");
return;
}
}
}
}
} catch (ApiFault af) {
System.out.println("\nFailed to succesfully reset password, error message was: \n" + af.getExceptionMessage());
getUserInput("\nHit return to continue...");
} catch (RemoteException ex) {
System.out.println("\nFailed to succesfully reset password, error message was: \n" + ex.getMessage());
getUserInput("\nHit return to continue...");
}
getUserInput("No password was reset....\nHit return to continue...");
}
Aggregations