This is working for me in php 5.5:
<?php
$ldap_host = 'ldap://ldap.example.com';
$base_dn = "ou=users,dc=example,dc=com";
$connect = ldap_connect($ldap_host);
$result = ldap_search($connect, $base_dn, "(cn=*)");
$entry = ldap_first_entry($connect, $result);
do {
$dn = ldap_get_dn($connect, $entry);
echo "DN is $dn\n";
} while ($entry = ldap_next_entry($connect, $entry));
ldap_close($connect);
?>