使用php连接到LDAP服务器

时间:2015-11-29 07:22:16

标签: php ldap domaincontroller

我想连接到LDAP服务器以获取使用php的OU列表。

    $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");
    }

运行代码后,我收到以下错误:

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

我不知道我的代码是否有任何问题或服务器配置有任何问题!?但是,我可以使用相同的LDAP用户名和密码通过AdExplorer连接到服务器。

0 个答案:

没有答案
相关问题