> 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/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://overleaf-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.
