Search code examples
apacheopenldap

How to use Form based LDAP authentication in apache


Could you please tell me how to use FORM in LDAP authentication instead of the default login pop up given by apache.

Below is the apache configuration,When I access a webpage I am getting the login page but after giving username,password i am not being redirected to the requested page instead login page comes again(i have checked the ldap credentials working in the default page and it work so no issue with the ldap)

<Location />
   # SetHandler form-login-handler
    AuthName example
    AuthFormProvider ldap
    AuthType form
    AuthFormLoginRequiredLocation http://localhost/login.html
    AuthBasicProvider ldap
    AuthLDAPURL ldap://localhost/dc=linuxbabe,dc=com?uid?sub?(objectClass=*)
   # Require ldap-filter objectClass=posixAccount
    Require valid-user
</Location>


   <Location "/login.html">
        Order allow,Deny
        Allow from all
        require all granted
    </Location>



    <Location /dologin.html>
      SetHandler form-login-handler
      AuthType form
      AuthName example
      AuthFormProvider ldap
      AuthFormLoginRequiredLocation http://localhost/login.html
    </Location>


<html>
<head><title>Test Login</title></head>
<body>

<form method="POST"  action="/dologin.html">
    Username: <input type="text" name="httpd_username" value="" />
    Password: <input type="password" name="httpd_password" value="" />
    <input type="submit" name="login" value="Login" />
    <input type="hidden" name="httpd_location"
value="http://localhost/index.html" />
</form>

</body>
</html>

Solution

  • Documentation of mod_auth_form says at the very beginning:

    Form authentication depends on the mod_session modules

    So you have to choose and configure one of the mod_session modules.