简体   繁体   中英

PHP ldap bind issue

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!

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

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

看看这个非常简单的示例: 如何使用PHP进行LDAP Active Directory身份验证

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM