> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/a/apple-device-management.md).

# Apple Device Management

The Apple device enrollment service lists devices bought for an organization. OctoXLabs reads the devices that are not assigned to an MDM. For MDM-managed devices, use the adapter of your MDM, for example Jamf or Intune.

## Use cases

* Find devices that Apple Device Management reports but your EDR does not cover.

```
Adapters = apple-device-management AND NOT Adapters = falcon-crowdstrike
```

* Review devices that Apple Device Management has not seen recently.

```
Adapters = apple-device-management AND NOT LastSeen last now-30d/d
```

* Check what one Apple Device Management connection collected.

```
Connections = YOUR_CONNECTION_NAME
```

## Before you begin

### Network

| Source              | Destination                                            | Port | Protocol |
| ------------------- | ------------------------------------------------------ | ---- | -------- |
| OctoXLabs connector | mdmenrollment.apple.com (default, configurable Domain) | 443  | HTTPS    |

### Required permissions

The token file comes from an MDM server entry in Apple Business Manager. Roles are not documented. Not verified.

## Create credentials in Apple Device Management

{% stepper %}
{% step %}

### Generate a key pair

Run `openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365`.
{% endstep %}

{% step %}

### Add an MDM server

Sign in to Apple Business Manager, go to **Settings** > **MDM Servers**. Select an existing server or click **Add MDM Server** and upload `cert.pem`.
{% endstep %}

{% step %}

### Download the token

Download the Token file (`.p7`).
{% endstep %}

{% step %}

### Decrypt it

Run `openssl smime -decrypt -inform smime -in fileFromApple.p7 -inkey key.pem`.
{% endstep %}

{% step %}

### Copy the four values

The decrypted file contains `consumer_key`, `consumer_secret`, `access_token` and `access_secret`.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter       | Required | Type    | Default                 | Description                                                           |
| --------------- | -------- | ------- | ----------------------- | --------------------------------------------------------------------- |
| Domain          | No       | String  | mdmenrollment.apple.com | Host name of the Apple DEP enrollment service.                        |
| Consumer Key    | Yes      | String  | None                    | OAuth consumer key, prefixed `CK_`.                                   |
| Consumer Secret | Yes      | String  | None                    | OAuth consumer secret, prefixed `CS_`.                                |
| Access Token    | Yes      | String  | None                    | OAuth access token, prefixed `AT_`.                                   |
| Access Secret   | Yes      | String  | None                    | OAuth access secret, prefixed `AS_`.                                  |
| Proxy           | No       | String  | None                    | Proxy address. The connector sends requests through `http://<value>`. |
| Timeout         | No       | Integer | 30                      | Time in seconds to wait for API responses.                            |

## Troubleshooting

| Error message                                                          | Cause                                                                  | Fix                                                                                                                                           |
| ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| Max retries (5) exceeded for                                           | The session token kept expiring.                                       | Check the four OAuth values.                                                                                                                  |
| Status Code: `, followed by the URL, the method and the response body` | The API answered with a status other than the one the adapter expects. | Read the code and body. 401 or 403 usually points to wrong credentials or missing permissions. Check the address, port and Is Secure setting. |

## Change history

{% hint style="info" %}
Available starting from version 6.3.2.
{% endhint %}
