sudo apt-get install libapache2-mod-authnz-ldap
LDAPTrustedGlobalCert CERT_BASE64 /path/to/cert/file.pem LDAPTrustedMode SSL LDAPVerifyServerCert on
LDAPReferrals off AuthType Basic AuthName "LDAP Authentication" AuthLDAPURL "ldap://example.com/dc=example,dc=com?sAMAccountName?sub?(objectClass=person)" AuthLDAPBindDN "cn=binduser,ou=users,dc=example,dc=com" AuthLDAPBindPassword "binduserpassword" Require valid-user
其中,LDAPTrustedGlobalCert、LDAPTrustedMode和LDAPVerifyServerCert用于配置SSL加密连接。LDAPReferrals off禁用重定向,AuthLDAPURL指定LDAP服务器的URL,AuthLDAPBindDN和AuthLDAPBindPassword指定绑定用户的DN和密码。
可以使用mod_authnz_ldap模块的Require ldap-group指令来限定LDAP组成员才能访问资源:
Require ldap-group cn=ldap_group,ou=groups,dc=example,dc=com
其中,Require ldap-group指定LDAP组的DN。
可以使用“ldapsearch”等工具来检查LDAP服务器的连接、配置和组成员等情况:
ldapsearch -H ldap://ldap_server:389 -x -D "cn=binduser,ou=users,dc=example,dc=com" -w binduserpassword -b "dc=example,dc=com" "memberof=cn=ldap_group,ou=groups,dc=example,dc