S.Amine
S.Amine

Reputation: 13

OpenLdap won't retrieve the userpassword

My problem is that when i try to retrieve the value of the attribute 'userPassword' it won't work i'm working under PHP , the problem is that the attribute exist when i open Phpldapadmin i can see it , but when i try to retrieve it using this lines of code it won't work

$sr = ldap_search($ds,"ou=people,dc=powerm,dc=com","uid=".$login);
$data = ldap_get_entries($ds,$sr);
$password = $data[0]["userpassword"][0];

$displayName = $data[0]["displayname"][0];
$num_tel =$data[0]["mobile"][0];
$mail =$data[0]["mail"][0]

the others attributes work fine expect the userpassword

can any one help ?

thanks.

Upvotes: 0

Views: 1405

Answers (1)

cv-pls
cv-pls

Reputation: 421

Try specifying the attributes you want returned explicitly.

$dn = 'ou=people,dc=powerm,dc=com';
$filter = 'uid=' . $login;
$attrs = ['displayname', 'userpassword', 'mobile', 'mail'];

$sr = ldap_search($ds, $dn, $filter, $attrs);

The directory may be configured not to return this security-sensitive attribute unless you explicitly ask for it.

It may also be that the attribute requires special privileges to access it - are you using the same credentials to connect to the database in your code as you did in phpLDAPAdmin?

The server may also be configured not to return the password unless it's over an encrypted connection - initiated using an ldaps:// URL passed to ldap_connect(), or using ldap_start_tls().

Upvotes: 2

Related Questions