ruby net ldap bind issue

Discussion in 'Ruby' started by Asif Iqbal, Jun 26, 2009.

  1. Asif Iqbal

    Asif Iqbal Guest

    $ cat ldap2.rb

    require 'rubygems'
    require 'net/ldap'

    ldap = Net::LDAP.new :host => "10.1.5.7",
    :port => 1636,
    :auth => {
    :method => :simple_tls,
    :username => "uid=sysldapq,ou=People,dc=mnet,dc=example,dc=com",
    :password => "June2008"
    }

    filter = Net::LDAP::Filter.eq( "uid", "iqbala*" )
    treebase = "ou=People,dc=mnet,dc=example,dc=com"

    ldap.search( :base => treebase, :filter => filter ) do |entry|
    puts "DN: #{entry.dn}"
    entry.each do |attribute, values|
    puts " #{attribute}:"
    values.each do |value|
    puts " --->#{value}"
    end
    end
    end

    p ldap.get_operation_result

    This is failing

    $ ruby ldap2.rb
    /var/lib/gems/1.8/gems/ruby-net-ldap-0.0.4/lib/net/ldap.rb:1097:in
    `bind': invalid binding information (Net::LDAP::LdapError)
    from /var/lib/gems/1.8/gems/ruby-net-ldap-0.0.4/lib/net/ldap.rb:639:in
    `search'
    from ldap2.rb:15



    However this works!

    $ ldapsearch -LLL -x -y .ldap-pass uid=username

    $ cat .ldaprc
    BINDDN uid=sysldapq,ou=people,dc=mnet,dc=example,dc=com

    $ cat /etc/ldap/ldap.conf
    #
    # LDAP Defaults
    #

    # See ldap.conf(5) for details
    # This file should be world readable but not world writable.

    BASE ou=People,dc=mnet,dc=example,dc=com
    URI ldaps://10.1.5.7:1636 ldaps://10.6.18.247:1636

    #SIZELIMIT 12
    #TIMELIMIT 15
    #DEREF never

    TLS_CACERT /etc/ssl/certs/exampleca.cer
    TLS_REQCERT never


    Any help would be appreciated

    --
    Asif Iqbal
    PGP Key: 0xE62693C5 KeyServer: pgp.mit.edu
    A: Because it messes up the order in which people normally read text.
    Q: Why is top-posting such a bad thing?
    Asif Iqbal, Jun 26, 2009
    #1
    1. Advertising

  2. Asif Iqbal

    Asif Iqbal Guest

    still need help with the ldaps

    On Fri, Jun 26, 2009 at 3:14 PM, Asif Iqbal<> wrote:
    > $ cat ldap2.rb
    >
    > require 'rubygems'
    > require 'net/ldap'
    >
    > =A0ldap =3D Net::LDAP.new :host =3D> "10.1.5.7",
    > =A0 =A0 =A0:port =3D> 1636,
    > =A0 =A0 =A0:auth =3D> {
    > =A0 =A0 =A0 =A0 =A0 =A0:method =3D> :simple_tls,
    > =A0 =A0 =A0 =A0 =A0 =A0:username =3D> "uid=3Dsysldapq,ou=3DPeople,dc=3Dmn=

    et,dc=3Dexample,dc=3Dcom",
    > =A0 =A0 =A0 =A0 =A0 =A0:password =3D> "June2008"
    > =A0 =A0 =A0}
    >
    > =A0filter =3D Net::LDAP::Filter.eq( "uid", "iqbala*" )
    > =A0treebase =3D "ou=3DPeople,dc=3Dmnet,dc=3Dexample,dc=3Dcom"
    >
    > =A0ldap.search( :base =3D> treebase, :filter =3D> filter ) do |entry|
    > =A0 puts "DN: #{entry.dn}"
    > =A0 entry.each do |attribute, values|
    > =A0 =A0 puts " =A0 #{attribute}:"
    > =A0 =A0 values.each do |value|
    > =A0 =A0 =A0 puts " =A0 =A0 =A0--->#{value}"
    > =A0 =A0 end
    > =A0 end
    > =A0end
    >
    > =A0p ldap.get_operation_result
    >
    > This is failing
    >
    > $ ruby ldap2.rb
    > /var/lib/gems/1.8/gems/ruby-net-ldap-0.0.4/lib/net/ldap.rb:1097:in
    > `bind': invalid binding information (Net::LDAP::LdapError)
    > =A0 =A0 =A0 =A0from /var/lib/gems/1.8/gems/ruby-net-ldap-0.0.4/lib/net/ld=

    ap.rb:639:in
    > `search'
    > =A0 =A0 =A0 =A0from ldap2.rb:15
    >
    >
    >
    > However this works!
    >
    > $ ldapsearch -LLL -x -y .ldap-pass uid=3Dusername
    >
    > $ cat .ldaprc
    > BINDDN =A0uid=3Dsysldapq,ou=3Dpeople,dc=3Dmnet,dc=3Dexample,dc=3Dcom
    >
    > $ cat /etc/ldap/ldap.conf
    > #
    > # LDAP Defaults
    > #
    >
    > # See ldap.conf(5) for details
    > # This file should be world readable but not world writable.
    >
    > BASE =A0 =A0ou=3DPeople,dc=3Dmnet,dc=3Dexample,dc=3Dcom
    > URI =A0 =A0 ldaps://10.1.5.7:1636 ldaps://10.6.18.247:1636
    >
    > #SIZELIMIT =A0 =A0 =A012
    > #TIMELIMIT =A0 =A0 =A015
    > #DEREF =A0 =A0 =A0 =A0 =A0never
    >
    > TLS_CACERT /etc/ssl/certs/exampleca.cer
    > TLS_REQCERT never
    >
    >
    > Any help would be appreciated
    >
    > --
    > Asif Iqbal
    > PGP Key: 0xE62693C5 KeyServer: pgp.mit.edu
    > A: Because it messes up the order in which people normally read text.
    > Q: Why is top-posting such a bad thing?
    >




    --=20
    Asif Iqbal
    PGP Key: 0xE62693C5 KeyServer: pgp.mit.edu
    A: Because it messes up the order in which people normally read text.
    Q: Why is top-posting such a bad thing?
    Asif Iqbal, Jun 29, 2009
    #2
    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:
    228
  2. Ian Macdonald
    Replies:
    0
    Views:
    206
    Ian Macdonald
    Mar 15, 2005
  3. James Hughes
    Replies:
    4
    Views:
    312
    James Hughes
    Dec 13, 2005
  4. Replies:
    1
    Views:
    192
    Austin Ziegler
    Oct 11, 2006
  5. dacat

    Net::LDAP vs ruby/ldap

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

Share This Page