I'm trying to retrieve a list of all users that exists on ldap, in order to create an autocomplete box in jquery. However, I do not manage to get it. I can connect and bind to the ldap server, then I try and use ldap_list()
. I leave a blank in the filter not to filter anything and get the entire list. However ldap_list()
sets a warning (Search: Can't contact LDAP server
) and returns FALSE
, which makes everything go wrong since it's a boolean and it's not what's expected (Warning: ldap_get_entries() expects parameter 2 to be resource, boolean given
). Here's a sample of my code:
$identifier = ldap_connect(sfConfig::get('sf_ldap_host'));
if (!ldap_bind($identifier,
sfConfig::get('sf_ldap_generic_user').sfConfig::get('sf_ldap_usr_domain'),
sfConfig::get('sf_ldap_generic_password')))
{
throw new sfException('could not bind to the Active Directory');
}
$list = ldap_list($identifier, sfConfig::get('sf_ldap_dn'), '', array('mail'));
$list_user = ldap_get_entries($identifier, $list);