No such object errors with Ruby-LDAP

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’, 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