# Provision users from Entra ID

> How Microsoft Entra ID sends users and their personal codes to Oktul eID SSO by SCIM, with the attribute mapping and where Entra ID keeps the code.
>
> Documentation for Oktul eID SSO for Jira, for Jira Cloud, by Oktul: https://oktul.com/docs/plugins/eid-sso/entra-provisioning/

Microsoft Entra ID tells the app who may log in. It sends each user's email address, a
permanent ID, an active flag and the personal code to the app's SCIM address. The app never
calls Entra ID and holds no Entra ID credentials.

## Two enterprise apps

Two enterprise apps in Entra ID provision the same users to two places.

| Enterprise app | Sends users to | Tenant URL and Secret Token |
|---|---|---|
| **Atlassian Cloud**, from Entra ID's gallery | Atlassian. It creates the Atlassian accounts and their groups, and deactivates people who leave | The **SCIM base URL** and **API key** Atlassian Guard shows when you set up user provisioning. See [Microsoft's tutorial](https://learn.microsoft.com/en-us/entra/identity/saas-apps/atlassian-cloud-provisioning-tutorial) |
| **An app of your own**, not from the gallery | Oktul eID SSO | The **Tenant URL** and **Secret token** on the app's **SCIM** tab |

Assign the same people to both. A person only Atlassian knows has an account and cannot log in
with eID. A person only the app knows authenticates and then has no Atlassian account to enter.

## The SCIM tab

The app's **SCIM** tab has what the second enterprise app needs, in three numbered parts.

| Part | What is on it |
|---|---|
| **1. Tenant URL** | The app's SCIM address, to copy |
| **2. Secret token** | **Generate SCIM token**, or **Replace SCIM token** once one exists, with the time the current token was generated. A new token shows once, under *Copy the token now*. The app keeps only a hash of it |
| **3. Personal codes** | The [form the code must have](#the-form-of-the-personal-code), and a mapping expression for Estonian codes |

Until a token exists, the tab says **No token**.

## Set up the second app

1. **In the app, open the SCIM tab** Copy the Tenant URL, select Generate SCIM token and copy the token. It is shown only this once.
2. **In the Microsoft Entra admin center, create an enterprise app** Enterprise apps, New application, Create your own application, and the option for an application you do not find in the gallery.
3. **Open its Provisioning page and enter the admin credentials** Paste the Tenant URL and the token as the Secret Token, then select Test Connection.
4. **Set the attribute mapping** Five rows, as the table below. Delete the others.
5. **Assign the users, and set the scope to Sync only assigned users and groups** Assign users only. The app accepts no groups.
6. **Provision one user on demand, then start provisioning**

Microsoft's guide to a SCIM app of your own is
[use SCIM to provision users](https://learn.microsoft.com/en-us/entra/identity/app-provisioning/use-scim-to-provision-users-and-groups).

## Attribute mapping

| Target attribute in the app | Entra ID source | Why |
|---|---|---|
| `userName` | `userPrincipalName` | Required and unique. Entra ID matches users by it |
| `emails[type eq "work"].value` | `mail` | The email **Atlassian knows the user by**, the same one the Atlassian Cloud app sends. The app signs the user in with it. Unique across users, in any letter case |
| `externalId` | `objectId` | Sent to Atlassian as the user's permanent ID. **Change Entra ID's default**, `mailNickname`, which can change. A user without it cannot log in |
| `active` | Entra ID's default expression | A disabled user cannot log in |
| `urn:ietf:params:scim:schemas:extension:oktul:2.0:User:nationalIdentifier` | The attribute that holds the personal code | The key an eID login is matched by. Add it to the target attribute list first, as below |

<Aside type="caution" title="Delete every other row">
Entra ID's default mapping sends about twenty attributes, among them the address, phone numbers,
the job title and the manager. The app accepts and ignores them, and they send personal data for
no purpose. Delete the row from `employeeId` to `employeeNumber` in particular: where the
personal code lives in `employeeId`, it would send the code a second time.
</Aside>

### Add the identifier attribute

Entra ID cannot discover the attribute by itself. Add it to the app's list of target
attributes:

1. On the app's **Attribute mapping** page, open the advanced options and edit the list of the
   target app's user attributes.
2. Add `urn:ietf:params:scim:schemas:extension:oktul:2.0:User:nationalIdentifier`, of type
   String, with nothing ticked.
3. Select **Add attribute mapping**, with that attribute as the target.

Microsoft describes the editor in
[customize attribute mappings](https://learn.microsoft.com/en-us/entra/identity/app-provisioning/customize-application-attributes).

## The form of the personal code

Send each personal code with its country, as `PNO`, the two-letter country, a hyphen and the
code:

| Country | Example |
|---|---|
| Estonia | `PNOEE-38001085718` |
| Latvia | `PNOLV-05040510009` |
| Lithuania | `PNOLT-40504040001` |

- **The digits alone are refused.** Estonian and Lithuanian codes share one structure and one
  check digit, so the same eleven digits can be valid in both countries and belong to two people.
  The app never assigns a country to bare digits.
- **Only the form is checked**: a known country and eleven digits. A Latvian code is also accepted
  with its hyphen after the sixth digit. A mistyped code is stored as sent, and that user gets
  *Account not found* at login.
- **Nothing is repaired.** Spaces, lower-case letters and other separators are refused. An error
  in Entra ID's data shows up as a provisioning error.

If Entra ID holds only the digits, build the full form in the mapping with an expression. The
**SCIM** tab has one to copy for Estonian codes:

```
Append("PNOEE-", [employeeId])
```

Apply such an expression only to users of that one country. For codes of several countries, keep
the full form in Entra ID.

## Where Entra ID keeps the personal code

The code usually comes from the HR or payroll system. Where it lands in Entra ID depends on your
setup.

| Setup | Entra ID attribute | Mapping |
|---|---|---|
| **Hybrid**, with an on-premises Active Directory synced to Entra ID | `extensionAttribute1` to `extensionAttribute15`, or a synced directory extension | An expression, for a bare code |
| **Cloud-only**, with codes from several countries | A directory extension holding the full form | Direct |
| **Cloud-only**, one country | `employeeId`, with the bare code | An expression |

`employeeId` holds at most 16 characters according to
[Microsoft Graph's documentation](https://learn.microsoft.com/en-us/graph/api/resources/user),
and can carry a bare code but not the full form. It is also often taken by the HR employee
number.

### Create a directory extension

A cloud-only tenant creates the extension once with Microsoft Graph PowerShell, on an app
registration kept only for it. Deleting that app registration deletes the attribute and its values.

```powershell
Connect-MgGraph -Scopes Application.ReadWrite.All,User.ReadWrite.All
$app = New-MgApplication -DisplayName "eID attributes"
New-MgServicePrincipal -AppId $app.AppId
New-MgApplicationExtensionProperty -ApplicationId $app.Id -Name nationalIdentifier -DataType String -TargetObjects User
```

Its value is set through Microsoft Graph, by a script or your HR connector, and not on the
user's page in the portal:

```powershell
Update-MgUser -UserId user@example.com -AdditionalProperties @{ "extension_<appId without dashes>_nationalIdentifier" = "PNOEE-38001085718" }
```

The source attribute list then shows it as `extension_<appId>_nationalIdentifier`. Microsoft's
guide is
[syncing extension attributes](https://learn.microsoft.com/en-us/entra/identity/app-provisioning/user-provisioning-sync-attributes-for-mapping).

<Aside type="note" title="Who can read the code in Entra ID">
None of these attributes is hidden from other members of your tenant, who can read user profiles
by default. Note it in your data protection impact assessment.
</Aside>

## What the app stores

For each user: `userName`, one email address, `externalId`, the active flag, the national
identifier, and the times the record was created and changed. Names, phone numbers and every
other attribute Entra ID sends are accepted and not stored.

- **Each value is unique.** A second user with a taken user name, email, `externalId` or
  identifier is refused with `409`. Two users with one email would both log in to the same
  Atlassian account.
- **The identifier is write-only.** No SCIM answer carries it.
- **A user without an identifier** is accepted and cannot log in with eID.

## When changes arrive

Entra ID sends changes on its own fixed cycle. **Provision on demand**, on the enterprise app's
**Provisioning** page, sends one user at once.

| In Entra ID | In the app | At login |
|---|---|---|
| A user is assigned | Created | Can log in |
| A user is disabled or unassigned | Marked inactive. The record and its code stay | *Account is not active* |
| A user is deleted for good | Deleted | *Account not found* |
| A personal code changes | Changed | The new code works after the next cycle |

According to [Microsoft](https://learn.microsoft.com/en-us/entra/identity/app-provisioning/how-provisioning-works),
Entra ID deletes a user for good 30 days after they were soft-deleted, and sends the delete then.

### Which Entra ID plan it needs

[Microsoft's licensing page](https://learn.microsoft.com/en-us/entra/fundamentals/licensing)
lists automated user provisioning under Entra ID Free, and provisioning logs and group
assignment under P1 and P2. It does not say whether that covers an enterprise app of your own.

We have provisioned a user on demand from a Free tenant. We have not confirmed that the
scheduled cycle runs there. On Free, check that a change arrives by itself before you rely on
it: the app's **Health** tab shows when Entra ID last used the token.

<Aside type="caution" title="Provision on demand shows the personal code">
Its result page lists every attribute it sent, the identifier included. Treat a screenshot of it
as personal data.
</Aside>

## Groups

- **The app accepts users only.** A request for groups is answered `404`. With the scope
  **Sync only assigned users and groups** and only users assigned, Entra ID sends none.
- **Nested groups are not read.** According to Microsoft, Entra ID provisions only the immediate
  members of an assigned group. Assign people directly, through flat groups or through a dynamic
  group.
- **Assigning a group needs Entra ID P1 or P2**, according to Microsoft.

## Help desk customers

Employees who only raise requests in Jira Service Management need no Jira or Jira Service
Management licence. They log in through the same single sign-on, and the app must know them too.

1. In Entra ID, give them the personal code and email like any other user, and assign them to
   both enterprise apps, without a group that grants product access.
2. In Atlassian Administration, keep them without product access and put them on the single
   sign-on policy.
3. In the service space, add them as customers. Create the Atlassian account first: a customer
   invited from Jira Service Management without one may get a portal-only account, which this
   single sign-on does not serve.

They then log in to the help center with their eID.

## What Entra ID reports when the app refuses a user

| Entra ID's provisioning log | Cause |
|---|---|
| `400 invalidValue` | The identifier is not in the form above. The message names the rule and never the value |
| `409 uniqueness` | Another user holds that user name, email, `externalId` or identifier |
| `409`, with *The user is being changed by another request; retry.* | Two requests changed the user at once. Entra ID sends it again in a later cycle |
| `401` | The token is wrong or was replaced. Paste the current one as the Secret Token |

The [SCIM API](../scim-api/) page lists every request the app answers.

## Common questions

**Why does Oktul eID SSO need users from Entra ID?**

An eID identifies a person by country and personal code, and Atlassian knows them by email. Entra ID sends the app both for each user, and the app uses the pair to find the account an eID login belongs to.

**Which attributes does Entra ID have to send?**

Five: the user name, the work email, a permanent ID as `externalId`, the active flag, and the national identifier in the form `PNOEE-38001085718`. The app stores those five and ignores everything else.

**Can the personal code be read back from the app?**

No. The identifier is write-only, and no SCIM answer carries it. A leaked SCIM token cannot read personal codes.

**What happens when a user is disabled in Entra ID?**

Entra ID marks the user inactive in the app on its next cycle, and their eID login ends with *Account is not active*. Atlassian's own provisioning deactivates the Atlassian account separately.

## Related

- [Set up eID login](../configure/)
- [SCIM API](../scim-api/)
- [Connect Atlassian Guard](../atlassian-guard/)
- [Privacy and data handling](../privacy/)

---

A problem or a question? Write to [support@oktul.com](mailto:support@oktul.com) or open a request in the [Help Center](https://support.oktul.com).
