I'm working on a project to change user AD password by using a token. How can I find a user DN with only the user EMAIL?
In other words I have the user e-mail and I want to get the user DN.
$result = ldap_mod_replace($ds, $UserDN , $userdata);
$ds = connection to ldap "Already done"
$userdata = User new password"Already done"
$UserDN = That's what I have the problem.
Really thank you guys. :)
Problem solved!
Code:
$res = ldap_search($ds, $basedn, $filter);
$first = ldap_first_entry($ds, $res);
$data = ldap_get_dn($ds, $first);
echo "The desired DN is: ".$data;
$userdata['unicodePwd'] = iconv('UTF-8', 'UTF-16LE',"\"" . $password1 . "\"");
$result = ldap_mod_replace($ds, $data , $userdata);