Discussion:
Net::LDAP::LdapError: no connection to server
Gustaf Lindqvist
2013-02-27 14:42:51 UTC
Permalink
Trying to establish a connection from a module in Rails and get no
connection to server. I have tested the same code outside Rails and it
works fine.

#!/usr/bin/ruby -w
require 'rubygems'
require 'net-ldap'

module Foo
module Bar
class User

attr_reader :ldap_connection

def initialize
@@ldap = Net::LDAP.new(:host => "<ip-number>", :port => 389)
@@treebase = "ou=People, dc=foo, dc=bar"
username = "cn=Manager"
password = "password"
@@ldap.auth username, password

begin
if @@ldap.bind
@ldap_connection = true
else
@ldap_connection = false
end
rescue Net::LDAP::LdapError
@ldap_connection = false
end
end
end
end
end

Any ideas why this is failing in Rails. Does net-ldap do any dns lookup
that might get wrong inside Rails stack?
--
You received this message because you are subscribed to the Google Groups "Ruby LDAP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-ldap+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Loading...