+1 vote
48 views

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:

<?php

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=*");
if(!$result){
    die(microtime(true).": ldap search returns false\r\n");
}

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

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

print_r($info);
?>

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 (3.3k points)   | 48 views

Please log in or register to answer this question.

Related questions

+2 votes
1 answer
asked May 3, 2020 by Antonio | 82 views
+2 votes
0 answers
+2 votes
1 answer
asked Oct 4, 2020 by toheed (1.4k points) | 55 views
+2 votes
0 answers
+1 vote
0 answers
asked Jun 16, 2020 by noor (1.1k points) | 24 views
+3 votes
1 answer
asked Apr 12, 2020 by athar (3.3k points) | 64 views
+2 votes
1 answer
+2 votes
0 answers
asked Jun 20, 2020 by athar (3.3k points) | 33 views
+3 votes
1 answer
asked Jun 19, 2020 by athar (3.3k points) | 32 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.
131 questions
94 answers
44 comments
134 users