#!/usr/bin/ruby
···
#
require 'ldap'
begin
ldap_host = 'corp.com'
ldap_port = 636
ldap_conn = LDAP::SSLConn.new(ldap_host,ldap_port)
puts "trace 2 ldap_conn: #{ldap_conn.class}"
ldap_conn.set_option( LDAP::LDAP_OPT_PROTOCOL_VERSION, 3 )
puts "trace 3 ldap_conn: #{ldap_conn.class}"
bind_dn = "uid=#{ARGV[0]},ou=People,ou=Corporate,dc=real,dc=com"
password_dn = "#{ARGV[1]}"
ldap_conn.bind(bind_dn,password_dn)
puts "trace 4 ldap_conn: #{ldap_conn.class}"
rescue
puts "trace 5 oops, #{$!}"
end
# end of test
I have a coworker who got this to work on his server, but on my Ubuntu Servers it won't go. We seem to have the configurations all correct. Is there a special configuration aspect or activity needed on Ubuntu servers for things like this? Changing the port to 389 and the SSLConn to Conn makes it go fine too, if that is any kind of a hint. Here is what the failures look like:
$ ./t7.rb un 'pw'
trace 2 ldap_conn: LDAP::SSLConn
trace 3 ldap_conn: LDAP::SSLConn
trace 5 oops, Can't contact LDAP server
$ ./t4.rb un 'pw'
trace 2 ldap_conn: LDAP::Conn
trace 3 ldap_conn: LDAP::Conn
trace 4 ldap_conn: LDAP::Conn
$
----snip---
where t4 is with just Conn/389 and t7 is with SSLConn and 636 as in my code above. Again, a coworker go the t7.rb running just like the t4 on his server, but mine don't take. We cannot find the config problem and the /etc/ldap directories seem to coincide for things that seem important.