Newer Version Available

This content describes an older version of this product. View Latest

setPassword()

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

Syntax

1SetPasswordResult setPasswordResult = connection.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

This sample accepts user ID and password parameters, which it uses in the setPassword() call to set the password of the specified user.

1swfobject.registerObject("clippy.codeblock-1", "9");public void doSetPassword(String userId, String newPasswd) {
2   try {
3      SetPasswordResult result = connection.setPassword(userId, newPasswd);
4      System.out.println("The password for user ID " + userId + " changed to "
5            + newPasswd);
6   } catch (ConnectionException ce) {
7      ce.printStackTrace();
8   }
9}

Sample Code—C#

This sample accepts user ID and password parameters, which it uses in the setPassword() call to set the password of the specified user.

1swfobject.registerObject("clippy.codeblock-2", "9");public void doSetPassword(String userId, String newPasswd)
2{
3   try
4   {
5      SetPasswordResult result = binding.setPassword(userId, newPasswd);
6      Console.WriteLine("The password for user ID " + userId + " changed to "
7            + newPasswd);
8   }
9   catch (SoapException e)
10   {
11      Console.WriteLine("An unexpected error has occurred: " +
12                        e.Message + "\n" + e.StackTrace);
13   }
14}

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.