简体   繁体   English

在不知道哈希函数的情况下更改ldap密码

[英]change ldap password without knowing the hash function

I am currently trying to change a password of an ldap account with ruby. 我目前正在尝试使用ruby更改ldap帐户的密码。 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. 正如我之前使用OpenDJ和Java一样,可以触发密码更改请求,该请求仅以纯文本形式获取新密码,但最后使用OpenLDAP选项中设置的功能将其设置为加密密码。

But with ruby, I only figured out how to change the password attribute directly. 但是对于ruby,我只想出了如何直接更改password属性。

Can I do the same with ruby what I do in java with OpenDJ? 我可以用ruby像在OpenDJ中用java做的一样吗?

The operation to change a password in OpenDJ is an LDAP operation, and independent of the language you are using on the client side. 在OpenDJ中更改密码的操作是LDAP操作,并且与您在客户端使用的语言无关。 So yes, you should be able to do the same with Ruby and Java. 是的,您应该能够使用Ruby和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. 在Ruby中如何进行操作取决于Ruby中提供的LDAP支持和库,很抱歉,我对此没有经验。

If you use the ruby-ldap gem the following code should work: 如果您使用ruby-ldap gem,则以下代码应该工作:

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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