# Seafile LDAP配置
在目前的 Seahub,只支持 email 格式的用戶名登陸,所以,使用 UNIX 和 Windows Domain 用戶名并不能登錄到 Seahub,后續版本中會對此進行改進.
Seafile 會通過數據庫和 LDAP 來搜尋用戶. 默認首先搜尋 LDAP. (請注意,在安裝時設置的 Seafile 管理員賬戶,會始終保存在 SQLite/MySQL 數據庫中。)
### LINUX 下連接LDAP/AD
請在`ccnet.conf`下增加以下語句,以使用 LDAP 進行用戶認證。
~~~
[LDAP]
# 主機的 LDAP URL, 支持ldap://, ldaps:// and ldapi://
# 為了使用 TLS, 請對 LDAP 服務器進行配置使其能夠監聽 LDAPS
# 端口, 并在這里指明 ldaps:// 地址.
HOST = ldap://ldap.example.com
# 設置所有用戶均可訪問 base DN
BASE = ou=users,dc=example,dc=com
# 管理員用戶 DN 綁定 LDAP. 如未設定,使用默認設置.
USER_DN = cn=seafileadmin,dc=example,dc=com
# 管理員用戶的 DN 密碼
PASSWORD = secret
# 用戶登陸ID, 默認使用郵件格式.
LOGIN_ATTR = mail
~~~
LDAP 配置示例:
~~~
[LDAP]
HOST = ldap://192.168.1.123/
BASE = ou=users,dc=example,dc=com
USER_DN = cn=admin,dc=example,dc=com
PASSWORD = secret
LOGIN_ATTR = mail
~~~
活動目錄(Active Directory)配置示例:
~~~
[LDAP]
HOST = ldap://192.168.1.123/
BASE = cn=users,dc=example,dc=com
USER_DN = cn=admin,cn=users,dc=example,dc=com # or use admin@example.local etc
PASSWORD = secret
LOGIN_ATTR = mail
~~~
如果你使用活動目錄(Active Directory)但并沒有向用戶提供 Email 地址,可進行如下配置::
~~~
[LDAP]
HOST = ldap://192.168.1.123/
BASE = cn=users,dc=example,dc=com
USER_DN = cn=admin,cn=users,dc=example,dc=com # or use admin@example.local etc
PASSWORD = secret
LOGIN_ATTR = userPrincipalName
~~~
`userPrincipalName`是 AD 提供的用戶名, 通常隸屬于`username@domain-name`, 而這里的`username`是指 Windows 用戶登錄名. 用戶可以通過`username@domain-name`登錄到 Seahub, 比如`poweruser@example.com`. 注意這樣的用戶登陸名并不是實際的 email 地址,Seahub 在這種設置下,郵件發送功能會失效.
注意:
1. 如果配置項包含中文,需要確保配置文件使用 UTF8 編碼保存。
1. 這個文檔中描述的配置方法經過很多人在不同的 LDAP/AD 環境下試過,肯定是能工作的。
### 通過 Windows 服務器連接到 LDAP/AD
Windows 下的配置語法與 Linux 下的有些不同. **你不需要增加`ldap:// prefix to the HOST field`.**
請在`ccnet.conf`下增加以下語句,以使用 LDAP 進行用戶認證。
~~~
[LDAP]
# 在 HOST 域指定 LDAP/AD 服務器端口
HOST = ldap.example.com[:port]
# 默認為 'false'. 如果希望 Seafile 可通過 SSL 連接到 LDAP 服務器,請設置為 true.
USE_SSL = true | false
# 設置所有用戶均可方位 base DN
BASE = ou=users,dc=example,dc=com
# 管理員用戶 DN 綁定 LDAP. 如未設定,使用默認設置.
USER_DN = cn=seafileadmin,dc=example,dc=com
# 管理員用戶的 DN 密碼
PASSWORD = secret
# 用戶登陸ID, 默認使用郵件格式.
LOGIN_ATTR = mail
~~~
LDAP 配置示例:
~~~
[LDAP]
HOST = 192.168.1.123
BASE = ou=users,dc=example,dc=com
USER_DN = cn=admin,dc=example,dc=com
PASSWORD = secret
LOGIN_ATTR = mail
~~~
活動目錄(Active Directory)配置示例:
~~~
[LDAP]
HOST = 192.168.1.123
BASE = cn=users,dc=example,dc=com
USER_DN = cn=admin,cn=users,dc=example,dc=com # or use admin@example.local etc
PASSWORD = secret
LOGIN_ATTR = mail
~~~
如果你使用活動目錄(Active Directory)但并沒有向用戶提供 email 地址,可進行如下配置::
~~~
[LDAP]
HOST = 192.168.1.123
BASE = cn=users,dc=example,dc=com
USER_DN = cn=admin,cn=users,dc=example,dc=com # or use admin@example.local etc
PASSWORD = secret
LOGIN_ATTR = userPrincipalName
~~~
`userPrincipalName`是 AD 提供的用戶名, 通常隸屬于`username@domain-name`, 而這里的`username`是指 Windows 用戶登錄名. 用戶可以通過`username@domain-name`登錄到 Seahub, 比如`poweruser@example.com`. 注意這樣的用戶登陸名并不是實際的 email 地址,Seahub 在這種設置下,郵件發送功能會失效.
### 多重基準標識名(Multiple base DN)/可選搜索過濾器(Additional search filter)
當你的公司在使用 Seafile 并且有多于一個 OUs 的時候,多重基準標識名多重基準標識名(Multiple base DN)會很有用處.你可以在"BASE"配置中指定一個基準標識名(base DN)的列表,標識名由";"分開, 比如: `cn=developers,dc=example,dc=com;cn=marketing,dc=example,dc=com`
當你的公司組織龐大,但是只有一小部分人使用 Seafile 的時候,搜索過濾器(Search filter)會很有用處. 過濾器可以通過修改"FILTER"配置來實現,例如,在 LDAP 配置中增加以下語句:
~~~
FILTER = memberOf=CN=group,CN=developers,DC=example,DC=com
~~~
請注意上面的示例只是象征性的簡介. `memberOf`只有在活動目錄(Active Directory)中才適用.
這里是另一個示例:
~~~
FILTER = &(!(UserAccountControl:1.2.840.113556.1.4.803:=2))
~~~
### 常見問題及解決方案
### Ubuntu/Debian 下 ldaps(LDAP over SSL)不能正常運行
請參考[這里](https://github.com/haiwen/seafile/issues/274)
這是因為預編譯安裝包是在 CentOS 下完成編譯與發布的,所以 libldap 會在`/etc/openldap/ldap.conf`查找配置文件. 而Ubuntu/Debian 使用的是`/etc/ldap/ldap.conf`這個配置文件. 所以在客戶端中找不到 CA 文件的路徑。
解決方法如下
~~~
mkdir /etc/openldap && ln -s /etc/ldap/ldap.conf /etc/openldap/
~~~
- 介紹
- 概覽
- Seafile 組件
- 研發路線圖
- 常見問題解答
- 修改日志
- 我要參與
- Linux 下部署 Seafile 服務器
- 部署 Seafile 服務器(使用 SQLite)
- 部署 Seafile 服務器(使用 MySQL)
- Nginx 下配置 Seahub
- Nginx 下啟用 Https
- Apache 下配置 Seahub
- Apache 下啟用 Https
- Seafile LDAP 配置
- 開機啟動 Seafile
- 防火墻設置
- Logrotate 管理系統日志
- 使用 Memcached
- 使用 NAT
- 非根域名下部署 Seahub
- 從 SQLite 遷移至 MySQL
- 安裝常見問題
- 升級
- Windows 下部署 Seafile 服務器
- 下載安裝 Windows 版 Seafile 服務器
- 安裝 Seafile 為 Windows 服務
- 所用端口說明
- 升級
- 從 Windows 遷移到 Linux
- 垃圾回收
- 部署 Seafile 專業版服務器
- 下載安裝 Seafile 專業版服務器
- 從社區版遷移至專業版
- 升級
- Amazon S3 下安裝
- OpenStackSwift 下安裝
- Ceph 下安裝
- 配置選項
- 文件搜索說明
- 集群部署
- 集群中啟用搜索和后臺服務
- NFS 下集群安裝
- 常見問題解答
- 軟件許可協議
- 服務器個性化配置
- ccnet.conf
- seafile.conf
- seahub_settings.py
- 發送郵件提醒
- 個性化郵件提醒
- 用戶管理
- 存儲容量與文件上傳/下載大小限制
- 自定義 Web
- 管理員手冊
- 賬戶管理
- 日志
- 備份與恢復
- Seafile FSCK
- Seafile GC
- WebDAV 和 FUSE 擴展
- WebDAV 擴展
- FUSE 擴展
- 安全選項
- 安全特性
- 日志和審計
- 開發文檔
- 編譯 Seafile
- Linux
- Windows
- Max OS X
- Server
- 開發環境
- 編程規范
- Web API
- Python API
- 數據模型
- 服務器組件
- 同步算法