--- title: Azure Active Directory integration with MDM description: Azure Active Directory is the world largest enterprise cloud identity management service. ms.assetid: D03B0765-5B5F-4C7B-9E2B-18E747D504EE ms.reviewer: manager: dansimp ms.author: dansimp ms.topic: article ms.prod: w10 ms.technology: windows author: dansimp --- # Azure Active Directory integration with MDM Azure Active Directory is the world largest enterprise cloud identity management service. It’s used by organizations to access Office 365 and business applications from Microsoft and third-party software as a service (SaaS) vendors. Many of the rich Windows 10 experiences for organizational users (such as store access or OS state roaming) use Azure AD as the underlying identity infrastructure. Windows integrates with Azure AD, allowing devices to be registered in Azure AD and enrolled into MDM in an integrated flow. Once a device is enrolled in MDM, the MDM: - Can enforce compliance with organization policies, add or remove apps, and more. - Can report a device’s compliance in Azure AD. - Azure AD can allow access to organization resources or applications secured by Azure AD to devices that comply with policies. To support these rich experiences with their MDM product, MDM vendors can integrate with Azure AD. This article describes the steps involved. ## Connect to Azure AD Several ways to connect your devices: For company-owned devices: - Join Windows to a traditional Active Directory domain - Join Windows to Azure AD For personal devices (BYOD): - Add a Microsoft work account to Windows ### Azure AD Join Company owned devices are traditionally joined to the on-premises Active Directory domain of the organization. These devices can be managed using Group Policy or computer management software such as Microsoft Endpoint Configuration Manager. In Windows 10, it’s also possible to manage domain joined devices with an MDM. Windows 10 introduces a new way to configure and deploy organization owned Windows devices. This mechanism is called Azure AD Join. Like traditional domain join, Azure AD Join allows devices to become known and managed by an organization. However, with Azure AD Join, Windows authenticates to Azure AD instead of authenticating to a domain controller. Azure AD Join also enables company owned devices to be automatically enrolled in, and managed by an MDM. Furthermore, Azure AD Join can be performed on a store-bought PC, in the out-of-box experience (OOBE), which helps organizations streamline their device deployment. An administrator can require that users belonging to one or more groups enroll their devices for management with an MDM. If a user is configured to require automatic enrollment during Azure AD Join, this enrollment becomes a mandatory step to configure Windows. If the MDM enrollment fails, then the device won't be joined to Azure AD. > [!IMPORTANT] > Every user enabled for automatic MDM enrollment with Azure AD Join must be assigned a valid [Azure Active Directory Premium](/previous-versions/azure/dn499825(v=azure.100)) license. ### BYOD scenario Windows 10 also introduces a simpler way to configure personal devices to access work apps and resources. Users can add their Microsoft work account to Windows and enjoy simpler and safer access to the apps and resources of the organization. During this process, Azure AD detects if the organization has configured an MDM. If that’s the case, Windows attempts to enroll the device in MDM as part of the “add account” flow. In the BYOD case, users can reject the MDM Terms of Use. The device isn't enrolled in MDM and access to organization resources is typically restricted. ## Integrated MDM enrollment and UX Two Azure AD MDM enrollment scenarios: - Joining a device to Azure AD for company-owned devices - Adding a work account to a personal device (BYOD) In both scenarios, Azure AD authenticates the user and the device. It provides a verified unique device identifier that can be used for MDM enrollment. In both scenarios, the enrollment flow provides an opportunity for the MDM service to render its own UI, using a web view. MDM vendors should use the UI to render the Terms of Use (TOU), which can be different for company-owned and BYOD devices. MDM vendors can also use the web view to render more UI elements, such as asking for a one-time PIN. In the out-of-the-box scenario, the web view is 100% full screen, which gives the MDM vendor the ability to paint an edge-to-edge experience. With great power comes great responsibility! It's important that MDM vendors who integrate with Azure AD respect the Windows design guidelines. This step includes using a responsive web design and respecting the Windows accessibility guidelines. For example, include the forward and back buttons that are properly wired to the navigation logic. More details are provided later in this article. For Azure AD enrollment to work for an Active Directory Federated Services (AD FS) backed Azure AD account, you must enable password authentication for the intranet on the ADFS service. For more information, see solution \#2 in [Configure Azure MFA as authentication provider with AD FS](/windows-server/identity/ad-fs/operations/configure-ad-fs-and-azure-mfa). Once a user has an Azure AD account added to Windows and enrolled in MDM, the enrollment can be managed through **Settings** > **Accounts** > **Work access**. Device management of either Azure AD Join for organization scenarios or BYOD scenarios is similar. > [!NOTE] > Users can't remove the device enrollment through the **Work access** user interface because management is tied to the Azure AD or work account. ### MDM endpoints involved in Azure AD–integrated enrollment Azure AD MDM enrollment is a two-step process: 1. Display the Terms of Use and gather user consent. This consent is a passive flow where the user is redirected in a browser control (webview) to the URL of the Terms of Use of the MDM. 2. Enroll the device. This step is an active flow where Windows OMA DM agent calls the MDM service to enroll the device. To support Azure AD enrollment, MDM vendors must host and expose a Terms of Use endpoint and an MDM enrollment endpoint. **Terms of Use endpoint** Use this endpoint to inform users of the ways in which their device can be controlled by their organization. The Terms of Use page is responsible for collecting user’s consent before the actual enrollment phase begins. It’s important to understand the Terms of Use flow is an "opaque box" to Windows and Azure AD. The whole web view is redirected to the Terms of Use URL. The user should be redirected back after approving or rejecting the Terms. This design allows the MDM vendor to customize their Terms of Use for different scenarios. For example, different levels of control are applied on BYOD vs. organization-owned devices. Or, implement user/group based targeting, like users in certain geographies may have stricter device management policies. The Terms of Use endpoint can implement more business logic, such as collecting a one-time PIN provided by IT to control device enrollment. However, MDM vendors must not use the Terms of Use flow to collect user credentials, which can be a degraded user experience. It’s not needed, since part of the MDM integration ensures that the MDM service can understand tokens issued by Azure AD. **MDM enrollment endpoint** After the users accepts the Terms of Use, the device is registered in Azure AD. Automatic MDM enrollment begins. The following diagram illustrates the high-level flow involved in the actual enrollment process. The device is first registered with Azure AD. This process assigns a unique device identifier to the device and presents the device with the ability to authenticate itself with Azure AD (device authentication). Then, the device is enrolled for management with the MDM. This step calls the enrollment endpoint and requests enrollment for the user and device. At this point, the user has been authenticated and device has been registered and authenticated with Azure AD. This information is available to the MDM in the form of claims within an access token presented at the enrollment endpoint.  The MDM is expected to use this information about the device (Device ID) when reporting device compliance back to Azure AD using the [Azure AD Graph API](/azure/active-directory/develop/active-directory-graph-api). A sample for reporting device compliance is provided later in this article. ## Make the MDM a reliable party of Azure AD To participate in the integrated enrollment flow outlined in the previous section, the MDM must consume access tokens issued by Azure AD. To report compliance with Azure AD, the MDM must authenticate itself to Azure AD and obtain authorization in the form of an access token that allows it to invoke the [Azure AD Graph API](/azure/active-directory/develop/active-directory-graph-api). ### Add a cloud-based MDM A cloud-based MDM is a SaaS application that provides device management capabilities in the cloud. It's a multi-tenant application. This application is registered with Azure AD in the home tenant of the MDM vendor. When an IT admin decides to use this MDM solution, an instance of this application is made visible in the tenant of the customer. The MDM vendor must first register the application in their home tenant and mark it as a multi-tenant application. Here a code sample from GitHub that explains how to add multi-tenant applications to Azure AD, [WepApp-WebAPI-MultiTenant-OpenIdConnect-DotNet](https://go.microsoft.com/fwlink/p/?LinkId=613661). > [!NOTE] > For the MDM provider, if you don't have an existing Azure AD tentant with an Azure AD subscription that you manage, follow the step-by-step guide in [Add an Azure AD tenant and Azure AD subscription](add-an-azure-ad-tenant-and-azure-ad-subscription.md) to set up a tenant, add a subscription, and manage it via the Azure Portal. The MDM application uses keys to request access tokens from Azure AD. These keys are managed within the tenant of the MDM provider and not visible to individual customers. The same key is used by the multi-tenant MDM application to authenticate itself with Azure AD, whatever the customer tenent the managed device belongs. Use the following steps to register a cloud-based MDM application with Azure AD. At this time, you need to work with the Azure AD engineering team to expose this application through the Azure AD app gallery. 1. Log in to the Azure Management Portal using an admin account in your home tenant. 2. In the left navigation, select **Active Directory**. 3. Select the directory tenant where you want to register the application. Ensure you're logged into your home tenant. 4. Select the **Applications** tab. 5. In the drawer, select **Add**. 6. Select **Add an application my organization is developing**. 7. Enter a friendly name for the application, such as ContosoMDM, select **Web Application and or Web API**, then select **Next**. 8. Enter the login URL for your MDM service. 9. For the App ID, enter **https://<your\_tenant\_name>/ContosoMDM**, then select OK. 10. While still in the Azure portal, select the **Configure** tab of your application. 11. Mark your application as **multi-tenant**. 12. Find the client ID value and copy it. You'll need this ID later when configuring your application. This client ID is used when obtaining access tokens and adding applications to the Azure AD app gallery. 13. Generate a key for your application and copy it. You need this key to call the Azure AD Graph API to report device compliance. This information is covered in the next section. For more information about how to register a sample application with Azure AD, see the steps to register the **TodoListService Web API** in [NativeClient-DotNet](https://go.microsoft.com/fwlink/p/?LinkId=613667). ### Add an on-premises MDM An on-premises MDM application is different than a cloud MDM. It's a single-tenant application that is present uniquely within the tenant of the customer. Customers must add the application directly within their own tenant. Also, each instance of an on-premises MDM application must be registered separately and has a separate key for authentication with Azure AD. To add an on-premises MDM application to the tenant, use the Azure AD service, specifically under **Mobility (MDM and MAM)** > **Add application**. Administrators can configure the required URLs for enrollment and Terms of Use. Your on-premises MDM product must expose a configuration experience where administrators can provide the client ID, app ID, and the key configured in their directory for that MDM application. You can use this client ID and key to request tokens from Azure AD when reporting device compliance. For more information about registering applications with Azure AD, see [Basics of Registering an Application in Azure AD](/previous-versions/azure/dn499820(v=azure.100)). ### Key management and security guidelines The application keys used by your MDM service are a sensitive resource. They should be protected and rolled over periodically for greater security. Access tokens obtained by your MDM service to call the Azure AD Graph API are bearer tokens and should be protected to avoid unauthorized disclosure. For security best practices, see [Windows Azure Security Essentials](https://go.microsoft.com/fwlink/p/?LinkId=613715). You can rollover the application keys used by a cloud-based MDM service without requiring a customer interaction. There's a single set of keys across all customer tenants that are managed by the MDM vendor in their Azure AD tenant. For the on-premises MDM, the Azure AD authentication keys are within the customer tenant and must be rolled over by the customer's administrator. To improve security, provide guidance to customers about rolling over and protecting the keys. ## Publish your MDM app to Azure AD app gallery IT administrators use the Azure AD app gallery to add an MDM for their organization to use. The app gallery is a rich store with over 2400 SaaS applications that are integrated with Azure AD. The following image show how MDM applications show up in the Azure app gallery.  ### Add cloud-based MDM to the app gallery > [!NOTE] > You should work with the Azure AD engineering team if your MDM application is cloud-based and needs to be enabled as a multi-tenant MDM application The following table shows the required information to create an entry in the Azure AD app gallery.
Item | Description |
---|---|
Application ID |
The client ID of your MDM app that is configured within your tenant. This ID is the unique identifier for your multi-tenant app. |
Publisher |
A string that identifies the publisher of the app. |
Application URL |
A URL to the landing page of your app where your administrators can get more information about the MDM app and contains a link to the landing page of your app. This URL isn't used for the actual enrollment. |
Description |
A brief description of your MDM app, which must be under 255 characters. |
Icons |
A set of logo icons for the MDM app. Dimensions: 45 X 45, 150 X 122, 214 X 215 |
CXH-HOST (HTTP HEADER) | Scenario | Background Theme | WinJS | Scenario CSS |
---|---|---|---|---|
FRX | OOBE | Dark theme + blue background color | Filename: Ui-dark.css | Filename: oobe-dekstop.css |
MOSET | Settings/
Post OOBE |
Light theme | Filename: Ui-light.css | Filename: settings-desktop.css |
Item | Description |
---|---|
redirect_uri |
After the user accepts or rejects the Terms of Use, the user is redirected to this URL. |
client-request-id |
A GUID that is used to correlate logs for diagnostic and debugging purposes. Use this parameter to log or trace the state of the enrollment request to help find the root cause of failures. |
api-version |
Specifies the version of the protocol requested by the client. This value provides a mechanism to support version revisions of the protocol. |
mode |
Specifies that the device is organization owned when mode=azureadjoin. This parameter isn't present for BYOD devices. |
Item | Description |
---|---|
Object ID |
Identifier of the user object corresponding to the authenticated user. |
UPN |
A claim containing the user principal name (UPN) of the authenticated user. |
TID |
A claim representing the tenant ID of the tenant. In the example above, it's Fabrikam. |
Resource |
A sanitized URL representing the MDM application. Example, https://fabrikam.contosomdm.com. |
Cause | HTTP status | Error | Description |
---|---|---|---|
api-version |
302 |
invalid_request |
unsupported version |
Tenant or user data are missing or other required prerequisites for device enrollment are not met |
302 |
unauthorized_client |
unauthorized user or tenant |
Azure AD token validation failed |
302 |
unauthorized_client |
unauthorized_client |
internal service error |
302 |
server_error |
internal service error |
Detail | Traditional MDM enrollment | Azure AD Join (organization-owned device) | Azure AD adds a work account (user-owned device) |
---|---|---|---|
MDM auto-discovery using email address to retrieve MDM discovery URL |
Enrollment |
Not applicable Discovery URL provisioned in Azure |
|
Uses MDM discovery URL |
Enrollment Enrollment renewal ROBO |
Enrollment Enrollment renewal ROBO |
Enrollment Enrollment renewal ROBO |
Is MDM enrollment required? |
Yes |
Yes |
No User can decline. |
Authentication type |
OnPremise Federated Certificate |
Federated |
Federated |
EnrollmentPolicyServiceURL |
Optional (all auth) |
Optional (all auth) |
Optional (all auth) |
EnrollmentServiceURL |
Required (all auth) |
Used (all auth) |
Used (all auth) |
EnrollmentServiceURL includes OS Version, OS Platform, and other attributes provided by MDM discovery URL |
Highly recommended |
Highly recommended |
Highly recommended |
AuthenticationServiceURL used |
Used (Federated auth) |
Skipped |
Skipped |
BinarySecurityToken |
Custom per MDM |
Azure AD issued token |
Azure AD issued token |
EnrollmentType |
Full |
Device |
Full |
Enrolled certificate type |
User certificate |
Device certificate |
User certificate |
Enrolled certificate store |
My/User |
My/System |
My/User |
CSR subject name |
User Principal Name |
Device ID |
User Principal Name |
EnrollmentData Terms of Use binary blob as AdditionalContext for EnrollmentServiceURL |
Not supported |
Supported |
Supported |
CSPs accessible during enrollment |
Windows 10 support:
|
Code | ID | Error message |
---|---|---|
0x80180001 | "idErrorServerConnectivity", // MENROLL_E_DEVICE_MESSAGE_FORMAT_ERROR | There was an error communicating with the server. You can try to do this again or contact your system administrator with the error code {0} |
0x80180002 | "idErrorAuthenticationFailure", // MENROLL_E_DEVICE_AUTHENTICATION_ERROR | There was a problem authenticating your account or device. You can try to do this again or contact your system administrator with the error code {0}. |
0x80180003 | "idErrorAuthorizationFailure", // MENROLL_E_DEVICE_AUTHORIZATION_ERROR | This user isn't authorized to enroll. You can try to do this again or contact your system administrator with the error code {0}. |
0x80180004 | "idErrorMDMCertificateError", // MENROLL_E_DEVICE_CERTIFCATEREQUEST_ERROR | There was a certificate error. You can try to do this again or contact your system administrator with the error code {0}. |
0x80180005 | "idErrorServerConnectivity", // MENROLL_E_DEVICE_CONFIGMGRSERVER_ERROR | There was an error communicating with the server. You can try to do this again or contact your system administrator with the error code {0} |
0x80180006 | "idErrorServerConnectivity", // MENROLL_E_DEVICE_CONFIGMGRSERVER_ERROR | There was an error communicating with the server. You can try to do this again or contact your system administrator with the error code {0} |
0x80180007 | "idErrorAuthenticationFailure", // MENROLL_E_DEVICE_INVALIDSECURITY_ERROR | There was a problem authenticating your account or device. You can try to do this again or contact your system administrator with the error code {0}. |
0x80180008 | "idErrorServerConnectivity", // MENROLL_E_DEVICE_UNKNOWN_ERROR | There was an error communicating with the server. You can try to do this again or contact your system administrator with the error code {0} |
0x80180009 | "idErrorAlreadyInProgress", // MENROLL_E_ENROLLMENT_IN_PROGRESS | Another enrollment is in progress. You can try to do this again or contact your system administrator with the error code {0}. |
0x8018000A | "idErrorMDMAlreadyEnrolled", // MENROLL_E_DEVICE_ALREADY_ENROLLED | This device is already enrolled. You can contact your system administrator with the error code {0}. |
0x8018000D | "idErrorMDMCertificateError", // MENROLL_E_DISCOVERY_SEC_CERT_DATE_INVALID | There was a certificate error. You can try to do this again or contact your system administrator with the error code {0}. |
0x8018000E | "idErrorAuthenticationFailure", // MENROLL_E_PASSWORD_NEEDED | There was a problem authenticating your account or device. You can try to do this again or contact your system administrator with the error code {0}. |
0x8018000F | "idErrorAuthenticationFailure", // MENROLL_E_WAB_ERROR | There was a problem authenticating your account or device. You can try to do this again or contact your system administrator with the error code {0}. |
0x80180010 | "idErrorServerConnectivity", // MENROLL_E_CONNECTIVITY | There was an error communicating with the server. You can try to do this again or contact your system administrator with the error code {0} |
0x80180012 | "idErrorMDMCertificateError", // MENROLL_E_INVALIDSSLCERT | There was a certificate error. You can try to do this again or contact your system administrator with the error code {0}. |
0x80180013 | "idErrorDeviceLimit", // MENROLL_E_DEVICECAPREACHED | Looks like there are too many devices or users for this account. Contact your system administrator with the error code {0}. |
0x80180014 | "idErrorMDMNotSupported", // MENROLL_E_DEVICENOTSUPPORTED | This feature isn't supported. Contact your system administrator with the error code {0}. |
0x80180015 | "idErrorMDMNotSupported", // MENROLL_E_NOTSUPPORTED | This feature isn't supported. Contact your system administrator with the error code {0}. |
0x80180016 | "idErrorMDMRenewalRejected", // MENROLL_E_NOTELIGIBLETORENEW | The server did not accept the request. You can try to do this again or contact your system administrator with the error code {0}. |
0x80180017 | "idErrorMDMAccountMaintenance", // MENROLL_E_INMAINTENANCE | The service is in maintenance. You can try to do this again later or contact your system administrator with the error code {0}. |
0x80180018 | "idErrorMDMLicenseError", // MENROLL_E_USERLICENSE | There was an error with your license. You can try to do this again or contact your system administrator with the error code {0}. |
0x80180019 | "idErrorInvalidServerConfig", // MENROLL_E_ENROLLMENTDATAINVALID | Looks like the server isn't correctly configured. You can try to do this again or contact your system administrator with the error code {0}. |
"rejectedTermsOfUse" | "idErrorRejectedTermsOfUse" | Your organization requires that you agree to the Terms of Use. Please try again or ask your support person for more information. |
0x801c0001 | "idErrorServerConnectivity", // DSREG_E_DEVICE_MESSAGE_FORMAT_ERROR | There was an error communicating with the server. You can try to do this again or contact your system administrator with the error code {0} |
0x801c0002 | "idErrorAuthenticationFailure", // DSREG_E_DEVICE_AUTHENTICATION_ERROR | There was a problem authenticating your account or device. You can try to do this again or contact your system administrator with the error code {0}. |
0x801c0003 | "idErrorAuthorizationFailure", // DSREG_E_DEVICE_AUTHORIZATION_ERROR | This user isn't authorized to enroll. You can try to do this again or contact your system administrator with the error code {0}. |
0x801c0006 | "idErrorServerConnectivity", // DSREG_E_DEVICE_INTERNALSERVICE_ERROR | There was an error communicating with the server. You can try to do this again or contact your system administrator with the error code {0} |
0x801c000B | "idErrorUntrustedServer", // DSREG_E_DISCOVERY_REDIRECTION_NOT_TRUSTED | The server being contacted isn't trusted. Contact your system administrator with the error code {0}. |
0x801c000C | "idErrorServerConnectivity", // DSREG_E_DISCOVERY_FAILED | There was an error communicating with the server. You can try to do this again or contact your system administrator with the error code {0} |
0x801c000E | "idErrorDeviceLimit", // DSREG_E_DEVICE_REGISTRATION_QUOTA_EXCCEEDED | Looks like there are too many devices or users for this account. Contact your system administrator with the error code {0}. |
0x801c000F | "idErrorDeviceRequiresReboot", // DSREG_E_DEVICE_REQUIRES_REBOOT | A reboot is required to complete device registration. |
0x801c0010 | "idErrorInvalidCertificate", // DSREG_E_DEVICE_AIK_VALIDATION_ERROR | Looks like you have an invalid certificate. Contact your system administrator with the error code {0}. |
0x801c0011 | "idErrorAuthenticationFailure", // DSREG_E_DEVICE_ATTESTATION_ERROR | There was a problem authenticating your account or device. You can try to do this again or contact your system administrator with the error code {0}. |
0x801c0012 | "idErrorServerConnectivity", // DSREG_E_DISCOVERY_BAD_MESSAGE_ERROR | There was an error communicating with the server. You can try to do this again or contact your system administrator with the error code {0} |
0x801c0013 | "idErrorAuthenticationFailure", // DSREG_E_TENANTID_NOT_FOUND | There was a problem authenticating your account or device. You can try to do this again or contact your system administrator with the error code {0}. |
0x801c0014 | "idErrorAuthenticationFailure", // DSREG_E_USERSID_NOT_FOUND | There was a problem authenticating your account or device. You can try to do this again or contact your system administrator with the error code {0}. |