How to reset ldap user password without old_password? Using the Net::Ldap gem or devise_ldap_authenticatable gem

1.5k Views Asked by At

I tried to reset a user password with the gem "devise_ldap_authenticatable" but it didn't work.

The command I tried to run was.

 Devise::LdapAdapter.update_password(login, new_password)

but it didn't work.

Unfortunately when it tries to bind it tries to bind the that user with a password nil since the old password is nil. I also tried to bind with the admin user credential but although the admin user is being logged in in; the password is not updated.

How would you reset a user ldap account password without using the 'old_password' as an admin user that have that privilege?

If you know a better solution, thanks to share!

2

There are 2 best solutions below

0
On

If you don't want to rely on 'iconv':

unicodepwd = "\"#{plain_text_password}\"".encode(Encoding::UTF_16LE).
  force_encoding(Encoding::ASCII_8BIT)
3
On

Transmit a modify request to the server using a modification type of 'replace', an attribute type of whatever the password attribute is, and the new password value. The authorization state of the connection performing the modify request must have access rights to the password attribute or have password-reset rights.