# Give an IAM user console access

Give an IAM user a console password, so a person signs in with your organization's alias and a user name, without an email account of their own.

Use it for a contractor, a shared operations login, or anyone you would rather not invite by email
address. Replace _alice_ with the IAM user's name.

## Prerequisites

- Permission for `iam:CreateLoginProfile` on the user. In the console, also `iam:GetUser` on the
  user to open its page (without it the page is not found) and `iam:GetLoginProfile` on the user:
  without it the **Console access** tab shows only that your policies do not grant it.
- In the console, also `iam:ListUsers` to open **Users** (without it the list says you do not have
  permission to list IAM users).
- An IAM user of type **User**, active, that no person signs in to with their own email account
  (see [Create an IAM user](create-an-iam-user.md)). Service accounts sign in with access keys.
- Console passwords for IAM users are on, and no single sign-on connection of your organization is
  enforced (see [Set the password policy](set-the-password-policy.md)).

## Turn on console access

**Console**
1. Open **Identity**, choose **Users**, then choose alice.
2. Choose **Console access**.
3. Under **Password**, choose **Generate one (shown once)**, or choose **Type one** and enter it
   for **New password**.
4. Keep **Ask for a new password at the next sign-in** selected, so only the user knows the
   password they use.
5. Choose **Turn on console access**.
6. A generated password is shown once. Copy it, then choose **Done**.

**CLI**
```sh
dcloud iam users create-login-profile user-id --generate-password
```

**API**
```http
POST /iam/api/users/user-id/login-profile
{ "generatePassword": true, "passwordResetRequired": true }
```

A generated password is in `generatedPassword`, once.

**Terraform**
```hcl
resource "dcloud_iam_user_login_profile" "alice" {
  user_id                 = dcloud_iam_user.alice.id
  generate_password       = true
  password_reset_required = true
}
```

The generated password is in `generated_password`, kept in the state.

## Result

The tab shows **How they sign in**: the **Sign-in link** (`https://<console host>/login/<alias>`),
the **Organization alias** (your organization's slug) and the **User name**. Send them the link and
the user name, and hand the password over separately.

They sign in at that link, or on the sign-in page with **Sign in with a user name from your
organization**, with **Organization alias or ID**, **User name** and **Password**. With a new
password due, they first see **Choose a new password**. If your organization has
**Require two-factor sign-in** on, they are sent to set up an authenticator app before they use the
console.

A generated password has 20 characters, or the policy's minimum length if that is longer, and
leaves out look-alike characters. A password you type must meet the password policy and may not
be the user name or the organization alias.

The IAM user acts only in your organization and only with what its policies allow: an IAM user with
no policies can sign in and do nothing. It cannot reset its password by email. Its sign-ins and
failures are in the audit log.

## If it is refused

- 409 `Service accounts sign in with access keys, not a console password.`
- 409 `This IAM user is suspended (for example a former member) and cannot be given console access. Invite the person again, or create a new IAM user.`
- 409 `This IAM user belongs to a person who signs in with their own email account.`
- 409 `This IAM user already has a console password. Reset it instead.`
- 409 `Another IAM user in this organization is also called "alice". User names must be unique to sign in with them.`
- 409 `Your organization has turned off console passwords for IAM users. Ask your administrator how to sign in.`
  or `Your organization signs in with single sign-on, so IAM-user console passwords are off. Ask your administrator.`
- 400 `The password does not meet the organization's policy: …`, with each rule broken, such as
  `Use at least 12 characters.`
- 400 `Give either password or generatePassword: true` when the request has neither, or both.

## Related

- [Manage console access](manage-console-access.md) · [Set the password policy](set-the-password-policy.md)
- `iam.users.create-login-profile` · `dcloud iam users create-login-profile` · `dcloud_iam_user_login_profile`
