Ruby LDAP 查询 Novell eDirectory

Ruby LDAP Query Novell eDirectory

我想使用 Ruby 连接到 Novell eDirectory,但我在 'open_connection' 上超时。

你怎么看?

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

错误

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)

您没有在端口 686 上连接到“172.21.45.60”。

我建议您在测试时尝试最初以纯文本形式建立连接。

所以开始真的很简单:

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

一旦成功,然后添加 TLS。

据我所见Ruby documentation(我不是Ruby高手),就是举个例子:

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

-吉姆