No such object errors with Ruby-LDAP...

Discussion in 'Ruby' started by augustf@gmail.com, Oct 13, 2006.

  1. Guest

    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
     
    , Oct 13, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason Wold

    using LDAP Controls in ruby-ldap

    Jason Wold, Nov 4, 2004, in forum: Ruby
    Replies:
    5
    Views:
    283
  2. Ian Macdonald
    Replies:
    0
    Views:
    241
    Ian Macdonald
    Mar 15, 2005
  3. James Hughes
    Replies:
    4
    Views:
    352
    James Hughes
    Dec 13, 2005
  4. Replies:
    1
    Views:
    234
    Austin Ziegler
    Oct 11, 2006
  5. dacat

    Net::LDAP vs ruby/ldap

    dacat, Apr 27, 2007, in forum: Ruby
    Replies:
    3
    Views:
    326
    Ian Macdonald
    May 18, 2007
Loading...

Share This Page