innovationfactory / ruby-net-ldap

Pure Ruby LDAP library
Other
31 stars 22 forks source link

Change Password #1

Closed sandrods closed 6 months ago

sandrods commented 15 years ago

Hi there... Is there any way to change a user password in AD, since the normal replace_attribute does not work in this case?

arcticleo commented 14 years ago

sandrods, did you manage? I ran in to the same issue as I used the replace_attribute on userPassword in an OS X 10.6 Server Open Directory to no avail.

sandrods commented 14 years ago

Yes I did, tough I don't quite remember how. I'll take a look at it tomorrow and get back to you, ok?

arcticleo commented 14 years ago

Thanks, I appreciate any help in this matter. /M

sandrods commented 14 years ago

Hi. It turns out the problem was the encoding of the password, not the method itself.

I used this code: ldap.replace_attribute(user.dn, 'unicodePwd', microsoft_encode_password(new_password))

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

It worked out. I don't know if this will work in OD, but it's worth a shot.

danmaispace commented 9 years ago

Does not work for Windows Server 2008 R2