Apache 伺服器使用 LDAP 認證

Apache 網頁除了可以使用 .htaccess 和 MySQL 的認證外,也可以使用 LDAP Server 來做使用者的認證。

1. 安裝所需的套件
# yum install mod_authz_ldap php-ldap

2. 建立測試目錄及檔案
# mkid /var/www/html/testldap
# echo “Test LDAP” > /var/www/html/testldap/index.html
[@more@]3. 修改設定檔
# vim /etc/httpd/conf.d/authz_ldap.conf
LoadModule authz_ldap_module modules/mod_authz_ldap.so

<IfModule mod_authz_ldap.c>

<Directory “/var/www/html/testldap”>
      AuthzLDAPMethod ldap
      # 192.168.154.167 為 LDAP Server IP
      AuthzLDAPServer 192.168.154.167
      AuthzLDAPUserBase ou=Teacher,dc=ldap,dc=tces.ilc.edu.tw
      AuthzLDAPUserKey uid
      AuthzLDAPUserScope base
#
      AuthType Basic
      AuthName “Test LDAP”
      require valid-user
#
</Directory>

4. 重新啟動 Apache Web Server
# service httpd restart

5. 進行測試

輸入正確的帳號及密碼,就可以看到測試的網頁