# No such object errors with Ruby-LDAP

**URL:** <https://www.ruby-forum.com/t/no-such-object-errors-with-ruby-ldap/72049>\
**Category:** Ruby\
**Created:** [October 13, 2006, 9:40pm UTC](https://www.ruby-forum.com/t/no-such-object-errors-with-ruby-ldap/72049 "2006-10-13T21:40:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [October 13, 2006, 9:40pm UTC](https://www.ruby-forum.com/t/no-such-object-errors-with-ruby-ldap/72049/1 "2006-10-13T21:40:54Z")

</div>

Hi everyone,  
I’m in the process of writing a small script for my LDAP-enabled  
Rails site (the script below has been converted to ruby shell form for  
easy testing). It will enable users to change their passwords. I didn’t  
use activeldap because of the issue of breaking the rest of the site  
(which also depends on ldap - activeldap support for multiple  
connections is really bad).

# Here’s the problem - every time I run this - I get a “no such object” error. Anyone know what I’m doing wrong?

require ‘ldap’  
require ‘base64’  
require ‘digest/md5’

newer\_pass = “{MD5}” + Base64.encode64(  
Digest::MD5.digest(“password”) ).chomp

reset = [LDAP.mod(LDAP::LDAP\_MOD\_REPLACE, “userPassword”,  
[newer\_pass]),]

conn = LDAP::Conn.new( ‘[rpisenate.com](http://rpisenate.com)’, 389 )  
conn.set\_option( LDAP::LDAP\_OPT\_PROTOCOL\_VERSION, 3 )  
conn.bind(‘cn=admin,dc=mysite,dc=com’, ‘admin\_pass’) do  
begin  
conn.modify(“uid=usersuid,ou=users,dc=mysite,dc=com”, reset)  
rescue LDAP::ResultError =\> msg  
puts "Can’t change password: " + msg  
exit 0  
rescue LDAP::Error =\> errcode  
puts "Can’t change password: " + LDAP.err2string(errcode)  
exit 0  
end  
end
