In this quick video learn how to setup LDAP/Active Directory authentication on an Apache webserver to secure web based applications.
Active Directory Setup
- Open Active Directory Users and Computers
- Expand the domain > Users
- Right Click Users > New > User
- Create a read only account to use for LDAP binding
First Name: Read
Last Name: Only
User logon name: readonly_svc - Click Next
- Set the user's password and confirm it
- Uncheck User must change password on next logon
- Check User cannot change password
- Check Password never expires
- Click Next
- Click Finish
- Right Click Users > New > Group
- Give the group a name and click OK
- Right Click the newly created group > Properties
- Select the Members tab > Click Add...
- Add users that will be allowed access to the web application
- Click OK
Configuring Apache HTTPD for LDAP
- Navigate to the Apache install directory/conf in Explorer
- Edit httpd.conf in a text editor
- Find the authnz_ldap_module and make sure it is enabled by removing the # at the start of the line
LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
- Find the ldap_module and make sure it is enabled by removing the # at the start of the line
LoadModule ldap_module modules/mod_ldap.so
- Create a Location block to enable LDAP authentication for the specified directory
<location /ldaptest>
# Basic authentication with LDAP against MS AD
AuthType Basic
AuthBasicProvider ldap
# AuthLDAPURL specifies the LDAP server IP, port, base DN, scope and filter
# using this format: ldap://host:port/basedn?attribute?scope?filter
AuthLDAPURL "ldap://i12bretro.local:389/DC=i12bretro,DC=local?sAMAccountName?sub?(objectClass=user)" NONE
# The LDAP bind username and password
AuthLDAPBindDN "readonly_svc@i12bretro.local"
AuthLDAPBindPassword "Read0nly!!"
LDAPReferrals Off
AuthUserFile /dev/null
AuthName "Restricted Area [i12bretro.local]"
# to authenticate a domain group, specify the full DN
AuthLDAPGroupAttributeIsDN on
require ldap-group CN=WebAuthAccess,CN=Users,DC=i12bretro,DC=local
</location> - Save httpd.conf
- Restart the Apache service
- Open a browser and navigate to the LDAP authenticated URL
- An authentication prompt should appear, allowing only users in the AD group specified access