# `resetPassword()`

Changes a user's password to a temporary, system-generated value.

## Syntax

```java
string password = connection.resetPassword(ID userID);
```

## Usage

Use [`resetPassword()`](/docs/platform/api/guide/sforce-api-calls-resetpassword.md) to request that the API change the password of a [User](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_user.htm) or [SelfServiceUser](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_selfserviceuser.htm), and return a system-generated password string of random letters and numbers. Use [`setPassword()`](/docs/platform/api/guide/sforce-api-calls-setpassword.md) instead if you want to set the password to a specific value.

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](/docs/platform/api/guide/calls.md).

For information on IDs, see [ID Field Type](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/field_types.htm#i1435616).

## Sample Code—Java

This sample resets the password for the user specified by the `userId` parameter. It calls `resetPassword()` with this ID and gets the temporary password from the call result. It writes this temporary password to the console and returns it.

```codesegment
public String doResetPassword(String userId) {
   String result = "";
   try {
      ResetPasswordResult rpr = connection.resetPassword(userId);
      result = rpr.getPassword();
      System.out.println("The temporary password for user ID " + userId
            + " is " + result);
   } catch (ConnectionException ce) {
      ce.printStackTrace();
   }
   return result;
}
```

## Sample Code—C\#

This sample resets the password for the user specified by the `userId` parameter. It calls `resetPassword()` with this ID and gets the temporary password from the call result. It writes this temporary password to the console and returns it.

```codesegment
public String doResetPassword(String userId)
{
   String result = "";
   try
   {
      ResetPasswordResult rpr = binding.resetPassword(userId);
      result = rpr.password;
      Console.WriteLine("The temporary password for user ID " + userId + " is " +
            result);
   }
   catch (SoapException e)
   {
      Console.WriteLine("An unexpected error has occurred: " +
                        e.Message + "\n" + e.StackTrace);
   }
   return result;
}
```

## Arguments

| Name     | Type | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| -------- | ---- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `userID` | ID   | ID of the [User](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_user.htm) or [SelfServiceUser](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_selfserviceuser.htm) whose password you want to reset. For information on IDs, see [ID Field Type](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/field_types.htm#i1435616). |

## Response

| Name       | Type   | Description                                                                                                                                                                                                                   |
| ---------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `password` | string | New password generated by the API. When the user logs in with this password, they’re asked to provide a new password. This password is temporary, meaning that it cannot be reused after the user has set their new password. |

## Fault

[`InvalidIdFault`](/docs/platform/api/guide/sforce-api-calls-concepts-core-data-objects.md)

[`UnexpectedErrorFault`](/docs/platform/api/guide/sforce-api-calls-concepts-core-data-objects.md)

**See Also**

- [Utility Calls](/docs/platform/api/guide/utility-calls.md)
