I'm doing LDAP authentication :
$server = '192.168.0.1';
$domain = '@meudom';
$port = 389;
$auth_user = 'usuario1';
$auth_pass = '123';
$ldap_connection = ldap_connect($server, $port) or die('Erro na conexão');
if (!$ldap_connection) exit('Falha na conexão');
ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, 0);
$bind = @ldap_bind($ldap_connection, $auth_user.$domain, $auth_pass);
if (!$bind) exit('Usuário e/ou senha incorreto(s)!');
$filter = "(uid={$auth_user})";
$result = ldap_search($ldap_connection, "(dc=meudom, dc=com)", $filter) or exit("Erro em search");
$entries = ldap_get_entries($ldap_connection, $result);
ldap_close($ldap_connection);
I saw some examples in searches, but all almost in a pattern.
Even the part of ldap_bind
is authenticating perfectly.
What I would like is to bring user data, among other possible information , but in $filter
, I have tested several ways:
- "(uid = {$ auth_user})"
- "(cn = *))"
- "(or = *))"
- etc
Always the result of print_r($entries)
is Array ( [count] => 0 )
.
I do not know if something is wrong in the ldap_search
part or elsewhere.