> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/rdm/knowledge-base/how-to-articles/rename-entra-id-accounts-domain.md).

# Rename Entra ID accounts domain

If you are using Remote Desktop Manager with the Entra ID integration and change your domain name and tenant, you will need to change them in your database for users to be able to log in.

You can use the SQL script below to rename your users to the correct domain.

{% hint style="success" %}
First make sure you have a backup of your SQL database since you will need to perform modifications on it.
{% endhint %}

1. In SSMS, connect to your Azure cloud/on-premises SQL Server and create a new query. Make sure it runs against your Remote Desktop Manager database and **not** your master.
2. Use the following script with your information:

```
DECLARE @oldDomain as varchar(255) = '@oldDomain'
DECLARE @newDomain as varchar(255) = '@newDomain'

UPDATE UserSecurity
SET Name=replace(Name,@oldDomain,@newDomain),
    UPN=replace(UPN,@oldDomain,@newDomain),
    ExternalID = NULL
WHERE UserType = 0

UPDATE UserProfile
SET Name=replace(Name,@oldDomain,@newDomain)
```

If you have changed your Azure tenant, you also need to do the following:

1. Run `Select*FROM sys.sysusers` to get a list of all the users.
2. For each user, drop them and re-create them using the following script:

```
DROP USER [user@domain.com];
CREATE USER [user@domain.com] FROM EXTERNAL PROVIDER;
```

3. Once the steps above are completed, you may need to "reset" the cache by changing your Azure plan and reverting back to the old plan afterwards for you users to be able to log in.

After having completed the steps above, the SID will contain the current information, and you should be able to authenticate with the old users.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.devolutions.net/rdm/knowledge-base/how-to-articles/rename-entra-id-accounts-domain.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
