> For the complete documentation index, see [llms.txt](https://wiki.datadike.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.datadike.com/pam/deploy-operate/rds-licensing.md).

# Remote Desktop Services licensing

How to license Remote Desktop Services, from Microsoft, on the Windows publishing host, and how to reset the 120-day grace period as a temporary measure.

## What this is and when to use it

Published applications (RemoteApp) and web sessions do not run on the PAM server. They run on a separate **Windows publishing host**, which uses the **Remote Desktop Session Host** (RDSH) role of Windows Server to hold several user sessions at once. That role belongs to Microsoft's **Remote Desktop Services** (RDS). RDS is licensed by Microsoft, separately from DataDike PAM: each user or device that connects to the host needs an **RDS client access licence** (CAL), issued by a **Remote Desktop license server**.

Until the host finds a license server, Windows allows a **grace period of 120 days**. When it runs out, the host refuses remote sessions, and every published application and web session that depends on it stops with it.

Use this page when you prepare a publishing host, and whenever the host reports that its grace period is running out.

The page also shows how to reset the grace period. The reset is a temporary measure that restores the 120 days while the licensing is put in place; it does not license the host.

## Before you start

* The publishing host: Windows Server. The **Remote Desktop Session Host** role is installed by the solution when the host is deployed.
* A server to act as the **license server**. It can be the publishing host itself or another Windows Server in the same network.
* **RDS CALs** acquired from Microsoft or a Microsoft reseller, of the type set in your agreement: **per user** or **per device**. The CAL version must be the same as, or later than, the Windows Server version of the publishing host.
* A **local administrator** account on both servers. For per-user CALs, the servers must belong to an Active Directory domain.
* Network reachability from the publishing host to the license server.

## Steps

### Check the grace period

1. On the publishing host, open **RD Licensing Diagnoser** (`lsdiag.msc`). It reports whether the host is still in its grace period and whether a license server and a licensing mode are configured.

Plan the licensing well before the count reaches zero.

### Install the license server

1. On the server chosen as license server, open **Server Manager › Add Roles and Features**, select **Remote Desktop Services**, and add the **Remote Desktop Licensing** role service. From PowerShell, the same is:

   ```powershell
   Install-WindowsFeature RDS-Licensing -IncludeManagementTools
   ```
2. Open **Remote Desktop Licensing Manager** (`licmgr.exe`), right-click the server, and choose **Activate Server**. Follow the wizard; the automatic connection method is the simplest when the server reaches the internet.
3. In a domain, right-click the server, choose **Review Configuration**, and add the server to the **Terminal Server License Servers** group if the wizard offers to.

### Install the CALs

1. In **Remote Desktop Licensing Manager**, right-click the server and choose **Install Licenses**.
2. Select the licence program of your agreement, enter the agreement data the wizard asks for, and choose the product version and the CAL type, **per user** or **per device**, with the quantity acquired.

### Point the publishing host at the license server

Two settings are needed on the publishing host: the license server to use, and the licensing mode. The mode must match the type of CAL installed.

**From the console**, when the host is deployed. In **Add virtual access machine**, the **Automation** step holds the RDS deployment options:

1. Enable **Existing RDS license**.
2. In **RDS License Server**, enter the name or address of the license server.
3. In **RDS Licensing Mode**, choose the mode that matches the CALs installed. The default is per device.

The deployment writes both settings into the Remote Desktop policy of the host. With **Existing RDS license** off, the deployment leaves licensing unset and the host runs on the 120-day grace period.

**With Group Policy** (local or domain), under **Computer Configuration › Administrative Templates › Windows Components › Remote Desktop Services › Remote Desktop Session Host › Licensing**:

1. Enable **Use the specified Remote Desktop license servers** and enter the name of the license server.
2. Enable **Set the Remote Desktop licensing mode** and choose **Per User** or **Per Device**.
3. Apply the policy with `gpupdate /force`.

**With PowerShell**, on the publishing host:

```powershell
$ts = Get-WmiObject -Namespace root\cimv2\terminalservices -Class Win32_TerminalServiceSetting
$ts.ChangeMode(4)                                            # 4 = Per User, 2 = Per Device
$ts.SetSpecifiedLicenseServerList("licserver.example.local")
```

The policy names above are the ones shown on an English-language Windows Server.

## What you should see

The publishing host reports the license server and the licensing mode you set, with no licensing warnings. Users keep opening published applications and web sessions through DataDike PAM, and the license server issues or tracks a CAL for each user or device that connects.

## How to verify it worked

1. On the publishing host, open **RD Licensing Diagnoser** (`lsdiag.msc`). It must show the licensing mode you set, the license server, and no problems found.
2. Open a published application or a web session through DataDike PAM as an ordinary user.
3. In **Remote Desktop Licensing Manager**, confirm the CALs appear as issued: per-device CALs are issued to the device that connected, and per-user CALs are tracked against the user.
4. Record the date, the CAL type, and the quantity installed.

## Reset the grace period

{% hint style="warning" %}
Resetting the grace period **does not license the host**. It is a temporary measure that restores the 120-day countdown while the licensing described above is put in place. The RDS CALs must be acquired and installed according to Microsoft's terms.
{% endhint %}

The reset is a direct edit of the Windows registry on the publishing host, followed by a restart.

### Before you reset

* A **local administrator** account on the publishing host.
* A **backup of the registry**, or a **snapshot** of the server. The procedure edits `HKLM` directly, and the deletion it ends with cannot be undone.
* A **maintenance window**. The restart ends every active session on the host, including the published applications and web sessions brokered through DataDike PAM.
* Access to the server's **own console**, local or through the hypervisor. Running this procedure over an RDP connection is not recommended.

### Find the grace period entry

1. On the publishing host, press **Win + R**, type `regedit`, and press **Enter**. When User Account Control asks, click **Yes** to run it as administrator.
2. In the left pane of the Registry Editor, go to:

   ```
   HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\RCM\GracePeriod
   ```
3. Inside the **GracePeriod** key, find the `REG_BINARY` entry whose name starts with `L$RTMTIMEBOMB`. It is normally the only entry in the key.

By default, the permissions on that entry do not allow it to be changed or deleted. They have to be changed first.

### Give the Administrators group full control

1. In the left pane, right-click the **GracePeriod** folder and choose **Permissions**.
2. Select the **Administrators** group, tick **Full Control**, and click **OK**.

If Windows reports an error when you apply the permission, take ownership of the key first, as described next. Otherwise, skip to *Delete the entry and restart*.

### Take ownership of the key (only if the permission could not be changed)

1. Right-click the **GracePeriod** folder and choose **Permissions** again, if the window is no longer open.
2. Click **Advanced**.
3. At the top of **Advanced Security Settings**, click **Change** next to the name of the current owner.
4. Type `Administrators` in the empty field and click **Check Names**. Confirm the local Administrators group was recognized, and click **OK**.
5. Tick **Replace owner on subcontainers and objects** and click **OK**.
6. Click **OK** again to close the permissions window, then give the Administrators group **Full Control** as described in the previous section.

### Delete the entry and restart

1. Right-click the `L$RTMTIMEBOMB…` entry, choose **Delete**, and confirm with **Yes**.
2. Press **F5** and confirm the entry is no longer listed under **GracePeriod**.
3. Close the Registry Editor.
4. Restart the publishing host. The restart ends every active session on it. The grace period is back at 120 days when the server comes up.

{% hint style="danger" %}
The deletion cannot be undone. Make sure the selected entry is the `L$RTMTIMEBOMB…` entry inside **GracePeriod** before you confirm.
{% endhint %}

### Verify the reset

1. Open **RD Licensing Diagnoser** (`lsdiag.msc`), or read the days left from an elevated PowerShell prompt on the host. Either must show 120 days:

   ```powershell
   (Invoke-WmiMethod -Path (Get-WmiObject -Namespace root\cimv2\terminalservices -Class Win32_TerminalServiceSetting).__PATH -Name GetGracePeriodDays).DaysLeft
   ```
2. Open a published application or a web session through DataDike PAM, and confirm it connects.
3. Record the date of the reset, and the date by which the licensing must be in place.

## Common errors

| Symptom                                                                                  | Cause                                                                                                                | Fix                                                                                 |
| ---------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| Users are disconnected with a message that no Remote Desktop license server is available | The grace period ran out and the host has no license server                                                          | Install and activate a license server with CALs, and point the host at it           |
| **RD Licensing Diagnoser** reports that the licensing mode is not configured             | The mode was never set on the publishing host, for example because it was deployed with **Existing RDS license** off | Set **Per User** or **Per Device** by policy or PowerShell                          |
| **RD Licensing Diagnoser** reports that the license server is not available              | Wrong server name, or the network between the two servers is blocked                                                 | Check the name in the policy, name resolution, and the firewall between the servers |
| CALs are installed but none is issued                                                    | The licensing mode does not match the CAL type                                                                       | Set the mode to the same type as the CALs installed                                 |
| Per-user CALs are not tracked                                                            | The servers are in a workgroup                                                                                       | Use per-device CALs, or join the servers to the domain                              |
| The license server cannot install CALs                                                   | The server was not activated                                                                                         | Run **Activate Server** before **Install Licenses**                                 |
| CALs are rejected by the host                                                            | The CAL version is older than the host's Windows Server version                                                      | Install CALs of the same version as the host, or later                              |
| The `L$RTMTIMEBOMB` entry cannot be deleted                                              | The permissions on **GracePeriod** were not changed                                                                  | Give the Administrators group **Full Control** on the key first                     |
| Applying **Full Control** fails with an error                                            | The Administrators group is not the owner of the key                                                                 | Take ownership of the key, then apply **Full Control** again                        |
| The grace period has not changed after the reset                                         | The host was not restarted, or another entry was deleted                                                             | Restart the host; check that the `L$RTMTIMEBOMB` entry is the one that was removed  |

## Field reference

| Setting                  | Where                                                                                                                                  | Values                                                                                                                                   |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| Remote Desktop Licensing | Role service of Remote Desktop Services, on the license server                                                                         | Installed and activated                                                                                                                  |
| CAL type                 | Chosen when the CALs are installed, by the agreement                                                                                   | Per user, per device                                                                                                                     |
| Licensing mode           | **RDS Licensing Mode** in the console, policy **Set the Remote Desktop licensing mode**, or `ChangeMode`                               | Per User (`4`), Per Device (`2`). The console default is per device                                                                      |
| License server           | **RDS License Server** in the console, policy **Use the specified Remote Desktop license servers**, or `SetSpecifiedLicenseServerList` | Name of the license server                                                                                                               |
| Grace period             | Windows, until a license server is found                                                                                               | 120 days                                                                                                                                 |
| Grace period entry       | Registry key `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\RCM\GracePeriod`                                     | Entry whose name starts with `L$RTMTIMEBOMB`, type `REG_BINARY`. Deleting it and restarting the host resets the grace period to 120 days |

## Related pages

* [System requirements](https://wiki.datadike.com/pam/deploy-operate/requirements.md)
* [RDP sessions](https://wiki.datadike.com/pam/administration/sessions/rdp.md)
* [Web sessions](https://wiki.datadike.com/pam/administration/sessions/web.md)
* [Platforms](https://wiki.datadike.com/pam/administration/assets/platforms.md)
