Sunday, May 26, 2013

Ldap authentication with wamp, php in windows


// using ldap bind$ldaprdn  'uname';     // ldap rdn or dn$ldappass 'password';  // associated password

// connect to ldap server
$ldapconn ldap_connect("ldap.example.com")
    or die(
"Could not connect to LDAP server.");

if (
$ldapconn) {

    
// binding to ldap server
    
$ldapbind ldap_bind($ldapconn$ldaprdn$ldappass);

    
// verify binding
    
if ($ldapbind) {
        echo 
"LDAP bind successful...";
    } else {
        echo 
"LDAP bind failed...";
    }

}

?>

to make this code, work check if your ldap is in fine condition and users are enabled to log in  with the ADS username and password. This can be checked by going to the ADS, service, right click the user and go to properties, in that select the logon tab, and check if he is valid to log in the computer.


No comments: