简体   繁体   中英

change ldap password without knowing the hash function

I am currently trying to change a password of an ldap account with ruby. As I used OpenDJ and Java before, it was possible to trigger a password change request which only got the new password as plain text but at the end it was set as crypted password using the function which was set in OpenLDAP options.

But with ruby, I only figured out how to change the password attribute directly.

Can I do the same with ruby what I do in java with OpenDJ?

The operation to change a password in OpenDJ is an LDAP operation, and independent of the language you are using on the client side. So yes, you should be able to do the same with Ruby and Java. How to do it in Ruby depends on the LDAP support and library provided in Ruby, and I'm sorry I have no experience with that.

If you use the ruby-ldap gem the following code should work:

modifications = [
  LDAP.mod(LDAP::LDAP_MOD_REPLACE, 'userPassword', ['cleartextpassword']),
]

begin
  conn.modify("uid=jdoe, dc=example, dc=com", modifications)
rescue LDAP::ResultError
  exit
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM