While developing a plugin, I had to search users on LDAP server using ldap_search() command and it was not finding them, but ldapsearch command in unix shell (ubuntu) did.
Problem was few lines above in my code, around ldap_connect(). For server address I input ldap://server.hostname, which turned to be the culprit.
Once I used only server.hostname, without protocol (ldap://), users where found and shown correctly.