1

I want to connect to a LDAP server to get a list of OUs using php.

    $ldaphost = "ldap://192.168.10.10";
    $ldapUsername  = "ldap_user";
    $ldapPassword = "xxxxxxxx";

    $ds = ldap_connect($ldaphost);

    if(!ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)){
        print "Could not set LDAPv3\r\n";
    }
    else if (!ldap_start_tls($ds)) {
        print "Could not start secure TLS connection";
    } 
    else {
    // binding to the ldap server
        $bth = ldap_bind($ds, $ldapUsername, $ldapPassword) or die("\r\nCould not connect to LDAP server\r\n");
    }

After running the code, I get the following error:

LDAP_START_TLS(): UNABLE TO START TLS: SERVER IS UNAVAILABLE

I don't know if either anything wrong with my code or any problem with server configuration!? However, I could connect to server through AdExplorer with the same LDAP username and password.

Hamid Ghorashi
  • 1,003
  • 3
  • 14
  • 29

0 Answers0