> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/on-premises/zh-tw/shi-yong-zhe-yu-zhuan-an-guan-li/user-management/username-migration.md).

# 使用者名稱遷移

## 使用者名稱遷移

從登入角度來看，使用者的主要識別資訊是其電子郵件地址。如果您是從本機驗證遷移到 SSO，或是從一個 IdP 遷移到另一個 IdP，您可能需要更新使用者的電子郵件地址。

為了協助這項作業，系統提供了一個腳本，可使用以下格式的 CSV 檔案來遷移使用者電子郵件：

`oldEmail,newEmail`

在完成一些驗證檢查後，腳本將逐列遍歷 CSV 檔案，並將使用者的電子郵件地址從 `oldEmail` 到 `newEmail`.

### **驗證**

在執行遷移之前， `<csv_file>` 將會被檢查以確保：

* 對於每一列， `oldEmail` 以及 `newEmail` 都是有效的電子郵件地址
* 沒有重複項目，例如，您沒有嘗試將不同使用者更新為相同的新電子郵件地址，或是您正嘗試以一個已被使用的電子郵件地址來更新同一個使用者帳號

### **用法** <a href="#usage" id="usage"></a>

{% code overflow="wrap" %}

```bash
docker cp <csv_file> sharelatex:/overleaf/services/web/<csv_file> docker exec sharelatex /bin/bash -c "cd /overleaf/services/web;node ./modules/server-ce-scripts/scripts/migrate-user-emails.js [--commit] [--continue|--ignore-missing] [--admin-id=ADMIN_USER_ID] <csv_file>"
```

{% endcode %}

### **旗標** <a href="#flags" id="flags"></a>

| 名稱                 | 描述                                                                                                                          |
| ------------------ | --------------------------------------------------------------------------------------------------------------------------- |
| `--commit`         | <p>加入 <code>--commit</code> 此旗標實際上會執行遷移。若未指定，遷移將以乾跑模式執行，不會進行任何變更，但仍會執行驗證。<br><br><strong>預設</strong>:<code>false</code></p> |
| `--continue`       | 此 `--continue` 若使用者帳號的電子郵件地址已經更新，則此旗標將繼續遷移程序                                                                                |
| `--ignore-missing` | 此 `--ignore-missing` 若找不到使用者帳號，則此旗標將繼續遷移程序                                                                                  |
| `--admin-id`       | 此 `--admin-id` 應設定為執行遷移的管理員 ID，並將用於稽核記錄項目。前往 **管理員** > **管理使用者** 並搜尋您的電子郵件地址，然後點擊第一個結果以找到您的使用者 ID。                          |
| `<csv_file>`       | 此 `<csv_file>` 是包含舊與新電子郵件地址的檔案                                                                                              |

### **完成** <a href="#completion" id="completion"></a>

在執行遷移腳本時，根據您選擇的旗標，將決定是否將錯誤記錄到主控台後繼續，或是記錄到主控台後結束。如果腳本因錯誤而提前終止，它將以代碼 1 結束，以表示執行失敗。

遷移完成後，腳本會將成功、失敗及略過的更新數量記錄到主控台。如果遷移成功完成，它將以代碼 0 結束。


---

# 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, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/on-premises/zh-tw/shi-yong-zhe-yu-zhuan-an-guan-li/user-management/username-migration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
