ruby net ldap bind issue

A

Asif Iqbal

$ 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
 
A

Asif Iqbal

still need help with the ldaps

$ 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?
 

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

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top