> For the complete documentation index, see [llms.txt](https://ayakaleaf-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://ayakaleaf-pro.ayaka.space/on-premises/zh-tw/shi-yong-zhe-yu-zhuan-an-guan-li/user-management/migrating-to-ldap-or-saml.md).

# 遷移至 LDAP 或 SAML

```
{
  _id:        '123',
  email:      'alice@example.com'
  first_name: 'Alice',
  last_name:  'Jones'
}
```

現在，你想要與貴公司的 LDAP/Active Directory 系統整合。在該系統中，Alice 的詳細資料如下：

```
Alice：
  - uid:  'alicejones'
  - mail: 'alicejones@tech.example.com'
  - givenName:   'Alice'
  - sn: 'Jones'
```

你的目標是讓 Alice 使用他們的 LDAP 使用者名稱（`alicejones`）和密碼登入，而不是舊的 Overleaf 憑證，同時不遺失任何工作。以下是實現方式。

{% hint style="warning" %}
這個程序需要重新建立 **sharelatex** 容器，這會造成一些停機時間。我們強烈建議你先在測試／預備環境中完整走過一遍這個流程，先熟悉它。
{% endhint %}

{% stepper %}
{% step %}

### 請使用者更新他們的電子郵件地址

Overleaf 帳戶是綁定電子郵件地址的，所以第一步是讓使用者的 Overleaf 電子郵件與其 LDAP 或 SAML 電子郵件同步。

在我們的例子中，你會要求 Alice 登入她的 Overleaf 帳戶，並將她的電子郵件從 `alice@example.com` 到 `alicejones@tech.example.com`.

{% hint style="warning" %}
別忘了你自己！如果你是管理員，也需要更新自己的電子郵件地址。
{% endhint %}

{% hint style="success" %}
如果你有很多使用者，可以使用 [使用者名稱遷移](/on-premises/zh-tw/shi-yong-zhe-yu-zhuan-an-guan-li/user-management/username-migration.md) 指令批次變更使用者的主要電子郵件地址。
{% endhint %}
{% endstep %}

{% step %}

### 啟用 LDAP 或 SAML 模組

當所有人的電子郵件地址都更新好之後，就該切換了！你需要為新的驗證方式設定正確的環境變數，然後重新建立 **sharelatex** 容器，並使用 `bin/up -d` 指令重新建立所有服務。

這會將標準的 Overleaf 登入表單替換成你新的 LDAP 或 SAML 表單。

{% hint style="info" %}
你可以找到啟用 LDAP 的相關資訊 [這裡](/on-premises/zh-tw/she-ding/overleaf-toolkit/authentication/ldap-authentication.md)，以及 SAML 2.0 [這裡](/on-premises/zh-tw/she-ding/overleaf-toolkit/authentication/saml-authentication.md).
{% endhint %}
{% endstep %}

{% step %}

### 使用者現在可以透過 LDAP 或 SAML 登入

下次 Alice 嘗試登入時，他們會看到新的表單。

![LDAP/Active Directory 登入頁面](/files/bbb22a894b6aa02d7aab08718d11e727c0db4eb4)

他們可以輸入他們的 LDAP 使用者名稱 (`alicejones`) 和密碼，而且由於他們的電子郵件地址現在與 LDAP 中的那個相符，他們將會直接登入現有的 Overleaf 帳戶。所有專案都會原封不動地保留在原位。

如果你已啟用 SAML 2.0，使用者會看到一個按鈕，點擊後會將他們重新導向到你的 IdP 以輸入憑證。驗證成功後，他們會被重新導回你的 Overleaf 執行個體，並登入自己的帳戶。

![SAML 登入頁面](/files/5516346f37fa245ec7694dd941c917519d3199a9)

{% hint style="info" %}
請參閱 [環境變數](broken://pages/bee4c82a30586f16dd4f9e8e432de3ea2df074eb) 頁面，了解如何自訂登入頁面的體驗。

如果你日後需要回復，只要將 LDAP/SAML 設定註解掉，然後重新建立 **sharelatex** 容器，並使用 `bin/up -d` 指令。之後使用者就能使用目前的電子郵件地址以及 Overleaf 專用密碼登入。
{% endhint %}
{% endstep %}
{% endstepper %}

## 反向操作：從 LDAP/SAML 切換回原生驗證

如果你已經使用 LDAP 或 SAML 一段時間，現在想改用 Overleaf 內建的登入系統（也許你已停用 LDAP）呢？沒問題！以下是切換方式。

{% stepper %}
{% step %}

### 檢查每個人的電子郵件是否正確

使用者的帳戶已經連結到他們的 LDAP 或 SAML 電子郵件地址。這就是他們之後登入時要使用的電子郵件，因此只要確認一切都正確即可。
{% endstep %}

{% step %}

### 停用 LDAP 或 SAML 模組

只要移除或取消設定 LDAP/SAML 設定，然後重新建立 **sharelatex** 容器，並使用 `bin/up -d` 指令。這將會恢復原生的 Overleaf 電子郵件與密碼登入表單。

![原生驗證登入頁面](/files/3d400cc403156d575a342d7816d09c6615757076)
{% endstep %}

{% step %}

### 請使用者重設密碼

當使用者現在造訪登入頁面時，他們會看到 Overleaf 登入表單，而不是 LDAP/SAML 表單。

由於他們可能從未有過原生的 Overleaf 密碼，因此需要建立一組。每位使用者應：

* 點擊「忘記密碼？」連結。
* 輸入與其帳戶相關聯的電子郵件地址（也就是 LDAP/SAML 的那個）。
* 依照密碼重設電子郵件中的連結來設定新密碼。

{% hint style="info" %}
如果你還沒這麼做，請查看我們關於啟用的指南 [電子郵件傳送](/on-premises/zh-tw/she-ding/overleaf-toolkit/email-delivery.md).
{% endhint %}

完成後，他們就可以使用電子郵件地址以及新的 Overleaf 專用密碼登入，以存取所有專案。
{% endstep %}
{% endstepper %}


---

# 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://ayakaleaf-pro.ayaka.space/on-premises/zh-tw/shi-yong-zhe-yu-zhuan-an-guan-li/user-management/migrating-to-ldap-or-saml.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.
