setPassword()

Sets the specified user’s password to the specified value.

Syntax

SetPasswordResult setPasswordResult = sfdc.setPassword(ID userID, string password);

Usage

Use setPassword() to change the password of a User or SelfServiceUser to a value that you specify. For example, a client application might prompt a user to specify a different password, and then invoke setPassword() to change the user’s password. Use resetPassword() instead if you want to reset the password with a random value generated by the API.

Your client application must be logged in with sufficient access rights to change the password for the specified user. For more information, see Factors that Affect Data Access.

For information on IDs, see ID Field Type.

This call can use the session ID returned in LoginResult if the password has expired. For more information, see passwordExpired.

Sample Code—Java

 public void setPasswordSample() {
   // Specify the userID and new password
   String idToReset = "005x0000000fFLnAAM";
   String newPassword = "password";
   try {
     // Invoke the setPassword call
     SetPasswordResult setPasswordResult = binding.setPassword(idToReset, newPassword);
     // If the call fails, an exception is raised; otherwise, the return is empty.
   } catch (Exception ex) {
     System.out.println("An unexpected error has occurred." + ex.getMessage());
   }
 }

Sample Code—C#

private void setPassword()
 {
     //Invoke setPassword call; returns nothing if successful
     binding.setPassword("userid", "newpassword");
 }

Arguments

Name Type Description
userID ID ID of the User or SelfServiceUser whose password you want to reset. For information on IDs, see ID Field Type.
password string New password to use for the specified user.

Response

None.

Fault

InvalidIdFault

UnexpectedErrorFault

See Also:
resetPassword()
Utility Calls
https://wiki.apexdevnet.com/index.php/Sample_SOAP_Messages
© Copyright 2000-2008 salesforce.com, inc. All rights reserved.
Various trademarks held by their respective owners.