'Apache LDAP auth

Here is my php code which works fine

    $ldapconfig['usersdn'] = '[email protected]';//CHANGE THIS TO THE CORRECT USER OU/CN
    $ds=ldap_connect("ldap://something.somewhere.com");
    ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
    ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
    ldap_set_option($ds, LDAP_OPT_NETWORK_TIMEOUT, 10);
    
    $dn = $ldapconfig['usersdn'];
    if(isset($_POST['txtuser'])){
        if ($bind=ldap_bind($ds, $dn, $password)) {
            session_start();
            $_SESSION['foo'] = 'bar';
        } else {
    
            echo "Login Failed: Please check your username or password";
        }
    }

I want to implement the same functionality on the apache server.

Here is my .htaccess file

AuthType Basic
AuthBasicProvider ldap
LDAPReferrals off
AuthLDAPBindAuthoritative off
AuthLDAPURL "ldap://something.somewhere.com"
AuthName "AD authentication"
Require valid-user

I'm also a bit confuse how to pass the username and password witch I enter to the dialog box.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source