ruby-ldap: uninitialized constant LDAP::LDAP_CONTROL_PAGEDRESULTS

Discussion in 'Ruby' started by James Hughes, Dec 13, 2005.

  1. James Hughes

    James Hughes Guest

    Hi,

    I'm trying to run the pr_ctl example script provided with the 0.9.2
    distribution of ruby-ldap. It dies with "./pr_ctl:41: uninitialized
    constant LDAP::LDAP_CONTROL_PAGEDRESULTS (NameError)".

    I need to use this control, but I can't figure out why this is
    happening. This constant is mentioned in ldap.c:

    #ifdef LDAP_CONTROL_PAGEDRESULTS
    rb_define_const (rb_mLDAP, "LDAP_CONTROL_PAGEDRESULTS",
    =09=09 rb_str_new2 (LDAP_CONTROL_PAGEDRESULTS));
    #endif

    I've installed the source distribution of ruby-ldap in place of the
    version that Debian provides. I thought perhaps the script was
    accessing an older version of the shared library, but there don't seem
    to be any old versions lying around. I've added
    /usr/local/lib/site_ruby/1.8/i486-linux (the location of the 0.9.2
    shared lib) to /etc/ld.so.conf and run ldconfig: no joy.

    Any other ideas on how to debug this?

    thanks
    jh


    --
    James Hughes
    Web application developer
    Centre for Health Services and Policy Research
    Vancouver, BC
     
    James Hughes, Dec 13, 2005
    #1
    1. Advertising

  2. James Hughes wrote:

    >
    > I need to use this control, but I can't figure out why this is
    > happening. This constant is mentioned in ldap.c:
    >
    > #ifdef LDAP_CONTROL_PAGEDRESULTS
    > rb_define_const (rb_mLDAP, "LDAP_CONTROL_PAGEDRESULTS",
    > rb_str_new2 (LDAP_CONTROL_PAGEDRESULTS));
    > #endif
    >


    That's a bug. Replace rb_str_new2 with INT2NUM.

    Regards,

    Dan
     
    Daniel Berger, Dec 13, 2005
    #2
    1. Advertising

  3. James Hughes

    James Hughes Guest

    On 12/13/05, Daniel Berger <> wrote:
    > James Hughes wrote:
    >
    > >
    > > I need to use this control, but I can't figure out why this is
    > > happening. This constant is mentioned in ldap.c:
    > >
    > > #ifdef LDAP_CONTROL_PAGEDRESULTS
    > > rb_define_const (rb_mLDAP, "LDAP_CONTROL_PAGEDRESULTS",
    > > rb_str_new2 (LDAP_CONTROL_PAGEDRESULTS));
    > > #endif
    > >

    >
    > That's a bug. Replace rb_str_new2 with INT2NUM.


    Done, rebuilt the .so, no joy. Same error. I have verified that the
    script is loading the correct shared lib by temporarily renaming it,
    which causes the script to die at "require 'ldap'".

    As I was about to send this response some of my gcc/make fu started
    returning to me, and I added "-DLDAP_CONTROL_PAGEDRESULTS" to the
    CPPFLAGS in the Makefile. Should have thought of that first.

    But now the script dies with
    "in `initialize': wrong argument type Fixnum (expected String) (TypeError)"

    This is the offending line:
    control =3D LDAP::Control.new(LDAP::LDAP_CONTROL_PAGEDRESULTS,
    ber_string,
    =09=09=09 critical )

    Anyone familiar with ruby-ldap know what's going on?

    thanks,
    jh


    jh

    --
    James Hughes
    Web application developer
    Centre for Health Services and Policy Research
    Vancouver, BC
     
    James Hughes, Dec 13, 2005
    #3
  4. James Hughes wrote:
    > On 12/13/05, Daniel Berger <> wrote:
    >
    >>James Hughes wrote:
    >>
    >>
    >>>I need to use this control, but I can't figure out why this is
    >>>happening. This constant is mentioned in ldap.c:
    >>>
    >>>#ifdef LDAP_CONTROL_PAGEDRESULTS
    >>> rb_define_const (rb_mLDAP, "LDAP_CONTROL_PAGEDRESULTS",
    >>> rb_str_new2 (LDAP_CONTROL_PAGEDRESULTS));
    >>>#endif
    >>>

    >>
    >>That's a bug. Replace rb_str_new2 with INT2NUM.

    >
    >
    > Done, rebuilt the .so, no joy.


    Whoops, that's not a bug. It's a string after all. Change that back to
    rb_str_new2.

    rb(main):001:0> require "ldap"
    => true
    irb(main):002:0> LDAP::LDAP_CONTROL_PAGEDRESULTS
    => "1.2.840.113556.1.4.319"

    Perhaps it's just not defined with your particular version of ldap?

    Regards,

    Dan
     
    Daniel Berger, Dec 13, 2005
    #4
  5. James Hughes

    James Hughes Guest

    On 12/13/05, Daniel Berger <> wrote:
    > rb(main):001:0> require "ldap"
    > =3D> true
    > irb(main):002:0> LDAP::LDAP_CONTROL_PAGEDRESULTS
    > =3D> "1.2.840.113556.1.4.319"
    >
    > Perhaps it's just not defined with your particular version of ldap?


    Of course. Don't know why I thought ruby-ldap would define this
    somewhere. Time to upgrade from openldap 2.2.26 I guess.
    jh


    --
    James Hughes
    Web application developer
    Centre for Health Services and Policy Research
    Vancouver, BC
     
    James Hughes, Dec 13, 2005
    #5
    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. =?ISO-8859-1?Q?Ney_Andr=E9_de_Mello_Zunino?=

    Uninitialized constant objects

    =?ISO-8859-1?Q?Ney_Andr=E9_de_Mello_Zunino?=, Jun 1, 2005, in forum: C++
    Replies:
    5
    Views:
    441
    Karl Heinz Buchegger
    Jun 1, 2005
  2. Replies:
    2
    Views:
    150
    zycte
    Jun 15, 2006
  3. Paul Varoutsos

    new to ruby: uninitialized constant

    Paul Varoutsos, Mar 14, 2009, in forum: Ruby
    Replies:
    3
    Views:
    157
    Justin Collins
    Mar 15, 2009
  4. Arti Singh
    Replies:
    2
    Views:
    111
    Arti Singh
    Dec 18, 2009
  5. Bob K.
    Replies:
    0
    Views:
    136
    Bob K.
    Jan 21, 2011
Loading...

Share This Page