1
votes

I want to connect to Novell eDirectory with Ruby, but I have TimeOut on 'open_connection'.

What do you think?

require 'net/ldap' 

    ldap = Net::LDAP.new :host => "172.21.45.60",
         :port => 686,
         :encrytion => :simple_tls,
         :auth => {
               :method => :simple,
               :username => "cn=XXX,ou=XXX,ou=XXX,o=XXX",
               :password => "XXX"
         }

    filter = Net::LDAP::Filter.eq("cn", "paul*")
    treebase = "ou=XXX,ou=XXX,o=XXX"
    attrs = ["mail", "cn", "sn", "objectclass", "loginTime"]

    ldap.search(:base => treebase, :filter => filter, :attributes => attrs) 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

Error

C:/Ruby23/lib/ruby/gems/2.3.0/gems/net-ldap-0.14.0/lib/net/ldap/connection.rb:63 :in `open_connection': Se produjo un error durante el intento de conexi¾n ya que la parte conectada no respondi¾ adecuadamente tras un periodo de tiempo, o bien se produjo un error en la conexi¾n establecida ya que el host conectado no ha p odido responder. - user specified timeout (Net::LDAP::Error)
1
your port is "686". I think this should be 636(for ssl) or 389.user3441151

1 Answers

1
votes

You are NOT making a conenction to "172.21.45.60" on port 686.

I would suggest you try to initially make connections in plain text when testing.

So start REALLY SIMPLE:

require 'rubygems'
require 'net/ldap'

ldap = Net::LDAP.new :host => server_ip_address,
     :port => 389,
     :auth => {
           :method => :simple,
           :username => "cn=manager,dc=example,dc=com",
           :password => "opensesame"
     }

filter = Net::LDAP::Filter.eq( "cn", "George*" )
treebase = "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

Once that works, then add TLS.

As I see the Ruby documentation (I am not Ruby Expert), is shows the example:

{
  :method => :start_tls,
  :tls_options => { :ca_file => "/etc/cafile.pem", :ssl_version => "TLSv1_1" }
}

-jim