+1 vote

I got this problem and have no idea to solve, can anyone give some suggestion?

The command line I use:

ldapsearch -LLL -h xxx -p xxx -x -D user01 -w aost.234 -b "DC=contoso,DC=com" "objectClass=*"

I can get result with command, but if I use the following php codes, I always got error with ldap_search function:


echo microtime(true).": start connect ldap server\r\n";
$ldapconn = ldap_connect('xxxx', xxx) or die("Could not connect to $ldaphost");

ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);

// ldap_set_option($ldapconn, LDAP_OPT_DEBUG_LEVEL, 7);
// ldap_set_option($ldapconn, LDAP_OPT_NETWORK_TIMEOUT, 5);

echo microtime(true).": ldap server connected, start bind ldap session\r\n";

$ldapbind = ldap_bind($ldapconn, 'user01', 'aost.234');

echo microtime(true).": ldap session binded, start search\r\n";

$result = ldap_search($ldapconn, "DC=contoso,DC=com", "objectClass=*");
    die(microtime(true).": ldap search returns false\r\n");

echo microtime(true).": ldap search result found\r\n";

$info = ldap_get_entries($ldapconn, $result);


I tried to execute this php and get this:

[root@localhost ~]# php ldap_test.php 
1512703670.3936: start connect ldap server
1512703670.3943: ldap server connected, start bind ldap session
1512703670.4689: ldap session binded, start search
PHP Warning:  ldap_search(): Search: Can't contact LDAP server in /media/sf_www/ldap_test.php on line 18
1512704185.0035: ldap search returns false
by (2.6k points)   | 10 views

Please log in or register to answer this question.

Related questions

+2 votes
1 answer
+2 votes
0 answers
+1 vote
0 answers
+3 votes
1 answer
asked Apr 12 by athar (2.6k points) | 31 views
+1 vote
1 answer
+2 votes
0 answers
asked Jun 20 by athar (2.6k points) | 12 views
+3 votes
1 answer
asked Jun 19 by athar (2.6k points) | 9 views

Welcome to Meansflow - Where Developers and Students Learn, Share, & Build Careers, where you can ask questions and receive answers from other members of the community.
108 questions
79 answers
99 users