Abstract: This article introduce how to configure the Apache to use LDAP authentication for the website access.
Ref:http://www.held-im-ruhestand.de/software/apache-ldap-active-directory-authentication.html
https://wiki.samba.org/index.php/Authenticating_Apache_against_Active_Directory
Install Module
Apache should be installed
1 | sudo yum install httpd mod_ssl |
Install the LDAP module
1 | sudo yum install mod_ldap -y |
After finishing the installation, you will find the corresponding *.so file in the apache directory.
1 | [dm@devops ~]$ ls /etc/httpd/modules/ | grep ldap |
Configuration
we just give the simplest way to configure the LDAP authentication for the welcome configuration.
after starting the httpd
, you will access the website on the server by visiting the IP address directly.
the default of welcome.conf
under the /etc/httpd/conf.d
the directory is as follows:
1 | # |
Now we add some configuration for the Directory, we suppose the LDAP server is AD Server, which will be use the AuthLDAPURL ldap://{AD-Hostname/IP}:389/cn=Users,dc={your Domain DN}?sAMAccountName?sub?(objectClass=*)
send bind request.
1 | # |
Then we need to restart the httpd
and try to access the website.
1 | sudo systemctl restart httpd |
we will see some dialog pop up and we need to input the AD server sAMAccountName and password. If input is right, we will see the previous welcome page. Or we will get 401 Unauthorized
page.
Disable the LDAP authentication cache
when debug, we want every time we need send LDAP request to server. So we’d better disable the LDAP cache.
1 | LDAPSharedCacheSize 500000 |
Add this configuration outside (Top level or in the root configuration file) and restart the httpd
, then the
Capture LDAP traffic by tShark
1 | sudo tshark -i ens192 -f "tcp port 389" -Y ldap -O ldap |
The short introduction for the usage:
-i
specific the network adapter interface
-f
filter the tcp port of LDAP default 389-Y ldap
display filter for LDAP-O ldap
output LDAP protocol only
https://www.wireshark.org/docs/wsug_html_chunked/AppToolstshark.html