No such object errors with Ruby-LDAP...

A

augustf

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top