Changing Passwords in Active Directory with ruby-net-ldap

I am building an application in Rails using ruby-net-ldap and I am
trying to figure out how to change passwords in Active Directory. Does
anyone have any experience with this using the ruby-net-ldap gem? I know
that I remember seeing an example on the web somewhere that showed how
to do this using the depot application from the Rails book but for the
life of me I can't find it again. :frowning: Any help would be greatly

Try replace_attribute:

from rdoc example for updating mail attribute:

  dn = "cn=modifyme,dc=example,dc=com"
  ldap.replace_attribute dn, :mail, ""

I haven't worked with Active Directory specifically, so might be
quirks regarding updating password (pre-digested/-encoded first,
or ...?) . Best to have other means of re-setting password while
testing what works.



Have you had any luck about this?

I'm having the same problem here...



Justin Grudzien wrote:


That did the trick.

Actually I used this code:

    def microsoft_encode_password(pwd)
      ret = ""
      pwd = "\"" + pwd + "\""
      pwd.length.times{|i| ret+= "#{pwd[i..i]}\000" }

so you don't need the Iconv dependency.

Thanks again,