0
I’m making authentication via LDAP:
$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’ve seen some examples in research, but all almost in a pattern.
Until the part of ldap_bind
is authenticating perfectly.
What I would like, is to bring the 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 don’t know if there’s really something wrong with the part about ldap_search
or another place.
It didn’t work. That’s right
ldap_search($ldap_connection, "(dc=meudom, dc=com)", $filter)
?– rbz
Yes, you can connect to the ldap server by another program ( ex Adexplorer ) to see the structure?
– Bruno Patrocinio
With you! I just tested.
– rbz
remove parentheses in search ldap_search($ldap_connection, "dc=meudom, dc=com", $filter)
– Bruno Patrocinio
Dude I just tested this, I hadn’t seen your comment rs... But that’s right! Put in the answer I already confirm! Thank you!
– rbz
I’ve already edited, confirm :D
– Bruno Patrocinio