How to configure htaccess authentication using LDAP

Htaccess authentication is usually configured with htpasswd file that contains username and encrypted passwords. But we can configured the same authentication with LDAP.

This article explains the steps to configure htaccess authentication using LDAP.

Step1: Enable Apache LDAP module. The module might be installed bydefault and ensure that the following lines are existing in the Apache configuration file.

LoadModule ldap_module modules/
LoadModule authnz_ldap_module modules/

This modules path might be different for different OS distributions. Also in some distributions we need to manually install the LDAP module.

Step2: Restart Apache service if the configuration file updated.

#systemctl restart httpd

Now we can use and configure ldap authentication in htaccess file.

Step3: Update htaccess file with the LDAP configuration.

Order deny,allow
Deny from All
AuthName "Restricted Area"
AuthType Basic
AuthBasicProvider ldap
AuthzLDAPAuthoritative off
AuthLDAPUrl ldap://,dc=company,dc=com?uid
Require valid-user
Satisfy any

Here we need to replace the ldap domain and details with the corresponding values.

That's all…

Leave a Reply