0

I've been looking at a couple of guides (and the PHP manual) trying to validate AD users on an intranet site I'm about to make. This is the first time I've used ldap_connect, and I haven't had the best of luck.

Could anyone look at my code and see what I'm missing?

Thanks.

<?php
    $user = "08jf1";
    $password = "pass";

    // Active Directory server
    $ldap_host = "10.43.48.5"; 

    // Active Directory DN
    $ldap_dn = "OU=CSE-W7,OU=Students-W7,DC=server,DC=local";

    // Domain, for purposes of constructing $user
    $ldap_usr_domain = "@server.local";

    // Connect to AD host
    $ldapconn = ldap_connect("10.43.48.5");

    if ($ldapconn) { 
            $bind = ldap_bind($ldap_host, $ldap_dn, $user . $ldap_usr_domain, $password);

            if ($bind) {
                echo "Verified user";

                //$_SESSION['username'] = $session_username;
                //$_SESSION['password'] = $session_password;

                } else {
                    echo "User does not exist";
                }
        }
?>

Edit: I can confirm ldap is enabled though phpinfo!

3 Answers 3

2

Is that syntax of ldap_bind correct?. Isn't it ldap_bind($ldapconn,$rdn,$password) ?

Sign up to request clarification or add additional context in comments.

Comments

0

Binding may need a elevated privilege or authbind wrapper. Refer to authbind for ldap. LDAP AuthBind

Comments

0

Take a look at this very simple example: How to use LDAP Active Directory Authentication with PHP

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.