BookStack 登入透過 LDAP / AD 驗證

依照 BookStack 官方說明要使用 LDAP / AD 作為登入驗證需先將下列設定值新增至 .env 檔案範例網域
◎ AD 網域: abc.com.tw
◎ AD 管理者帳號 / 密碼: administrator / 123456

 

 
# General auth
AUTH_METHOD=ldap
 
# The LDAP host, Adding a port is optional
LDAP_SERVER=abc.com.tw:389
# If using LDAP over SSL you should also define the protocol:
# LDAP_SERVER=ldaps://example.com:636
 
# The base DN from where users will be searched within
LDAP_BASE_DN=dc=abc,dc=com,dc=tw
 
# The full DN and password of the user used to search the server
# Can both be left as false to bind anonymously
LDAP_DN= cn=administrator,cn=users,dc=abc,dc=com,dc=tw
LDAP_PASS=123456
 
# A filter to use when searching for users
# The user-provided user-name used to replace any occurrences of '${user}'
LDAP_USER_FILTER=(&(sAMAccountName=${user}))
#以 AD 帳號的 sAMAccountName 值作為 BookStack 的帳號。
 
# Set the LDAP version to use when connecting to the server
LDAP_VERSION=3
 
# Set the default 'email' attribute. Defaults to 'mail'
LDAP_EMAIL_ATTRIBUTE=mail
#以 AD 帳號的 mail 值作為 BookStack 帳號的 mail 值。
 
# Set the property to use for a user's display name. Defaults to 'cn'
LDAP_DISPLAY_NAME_ATTRIBUTE=cn
#以 AD 帳號的 cn 值作為 BookStack 帳號的顯示名稱。
#這邊如果改成 sAMAccountName,BookStack 仍會帶到 cn,原因不明。
 
# If you need to allow untrusted LDAPS certificates, add the below and uncomment (remove the #)
# Only set this option if debugging or you're absolutely sure it's required for your setup.
#LDAP_TLS_INSECURE=true

◎ 修改的參數過程只要儲存 .env 檔即可套用新的設定值不需要重啟 Apache
◎ 「顯示名稱」若有空格會顯示不完整

 

  改完生效後會發生一個問題當以 AD 管理者 (administrator) 登入時沒有管理者權限而原本 BookStack 的管理者 (admin@admin.com) 又已無法登入依照官方說明請依下列步驟設定
1. 先關閉 .env 的 LDAP/AD 驗證設定
2. 以 BookStack 的管理者帳戶 (admin@admin.com) 登入
3. 開啟 .env 的 LDAP/AD 驗證設定
4. 到編輯使用者資料頁面會有個「外部身份驗證ID」欄位輸入CN=Administrator,CN=Users,DC=abc,DC=com,DC=tw” (大小寫不可有誤),把BookStack 管理者 (admin@admin.com)跟 AD 管理者 (administrator)串起來

5. 登出以 AD 管理者 (administrator) 登入即可擁有管理者權限
 

 

2 則留言

  1. Daniel Chou says:

    版主好
    請問
    1. “名稱能用中文名嗎?
    2. 外部身份這個欄位我能這樣填嗎?
    CN=danielchou, CN=users, DC=abc,DC=local

    感謝

    1. Anson says:

      您好
      1.我印象是可以的
      2.要看你的AD架構假設danielchou是在users底下那你打的那串就沒錯
      謝謝

  2. More Comments..

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.