Author Topic: Password changing from PHP  (Read 2327 times)

petho.jonatan

  • Zen Apprentice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Password changing from PHP
« on: February 23, 2016, 07:56:40 pm »
Hi there,

I tried to change the password of an ldap user from php. I tried it several ways. The closest way was the following: I made a bind with the username and password to check if it's correct. After that made a bind with a user with admin rights and wrote the following lines:

$newPassword_md5 = "{MD5}" . base64_encode(pack("H*", md5($newPassword)));
$userData = array("userPassword" => $newPassword_md5);
ldap_mod_replace($this->admin_connection, $this->user_dn, $userData);

It has written the userPassword property to the ldap user, but the password wasn't changed in fact. I tried another way. Made the replace with unicodePwd with the encoded password:

$newPassword = "\"" . $newPassword . "\"";
$len = strlen($newPassword);
for($i = 0; $i < $len; $i++) {
    $newPassw .= "{$newPassword{$i}}\000";
}
$newPassword = $newPassw;
$userdata['unicodePwd'] = $newPassword;

It throwed an error message:  PHP Warning:  ldap_mod_replace(): Modify: Server is unwilling to perform in /var/www/ ...

Can you give me the correct way to perform the password changing?

andersonpem

  • Zen Apprentice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Password changing from PHP
« Reply #1 on: February 28, 2016, 08:38:12 am »
I am also looking for a solution for this issue. We want to integrate our intranet in such way the user can change his password through our web intranet, which is PHP-based.  ;D

petho.jonatan

  • Zen Apprentice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Password changing from PHP
« Reply #2 on: April 30, 2016, 09:11:02 am »
Have you found the solution?