Scientific Linux 6
Sponsored Link

Basic Auth + LDAP2011/03/20

  Configure httpd and set a page that people must authenticate and the authentication is from LDAP server. Therefore it's necessarry to run LDAP server in your LAN.

[1] It needs 'mod_authnz_ldap7 module, but it's loaded by default. If your httpd does not load it, add following lines in your httpd.conf.
LoadModule ldap_module modules/mod_ldap.so

LoadModule authnz_ldap_module modules/mod_authnz_ldap.so

Following example shows 'test' directory requires an authentication.
[root@www ~]#
vi /etc/httpd/conf.d/auth.conf


# create new

<IfModule authnz_ldap_module>
<Directory /var/www/html/test>

SSLRequireSSL

AuthName "Authentication"

AuthType Basic

AuthBasicProvider ldap

AuthLDAPURL ldap://10.0.0.100/dc=srv,dc=world?uid?sub?(objectClass=*)

Require ldap-filter objectClass=posixAccount

</Directory>

</IfModule>


[root@www ~]#
/etc/rc.d/init.d/httpd restart

Stopping httpd:
[  OK  ]

Starting httpd:
[  OK  ]


[root@www ~]#
vi /var/www/html/test/index.html


# create a test page

<html>
<body>
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
Test Page for LDAP Auth
</div>
</body>
</html>
  Access to the test page with web browser, then authentication is required as a config. Input a LDAP user and authenticate here.
 
  Just accessed.
 
Matched Content