LDAP Issues

Hi All

I am at wits end trying to get LDAP to work in Rails running on ubuntu (yes, I'm a noob!). I have version 0.9.7 of ruby-ldap installed. Every thing seems fine, until I test in the console:

>> require 'ldap' => ["LDAP"] >> l = LDAP::Conn.new('xxxx.xxxx.xxxx.net', 389) => #<LDAP::Conn:0xb74a4a40> >> l.set_option( LDAP::LDAP_OPT_PROTOCOL_VERSION, 3 ) => #<LDAP::Conn:0xb74a4a40> >> l.bind('cn=xxxx,dc=xxxx,dc=xxxx,dc=xxxx', 'xxxxxxx') LDAP::ResultError: Can't contact LDAP server          from (irb):4:in `bind'          from (irb):4

Now, it appears that a connection object is created, but yet it says that it can't contact the server. I can telnet to the relevant server so there is connectivity but further than that, I have no idea.

Any clues as to what might be causing this?

All help appreciated.

Rory

Hi All

I am at wits end trying to get LDAP to work in Rails running on ubuntu (yes, I'm a noob!). I have version 0.9.7 of ruby-ldap installed. Every thing seems fine, until I test in the console:

>> require 'ldap' => ["LDAP"] >> l = LDAP::Conn.new('xxxx.xxxx.xxxx.net', 389) => #<LDAP::Conn:0xb74a4a40> >> l.set_option( LDAP::LDAP_OPT_PROTOCOL_VERSION, 3 ) => #<LDAP::Conn:0xb74a4a40> >> l.bind('cn=xxxx,dc=xxxx,dc=xxxx,dc=xxxx', 'xxxxxxx') LDAP::ResultError: Can't contact LDAP server          from (irb):4:in `bind'          from (irb):4

Now, it appears that a connection object is created, but yet it says that it can't contact the server. I can telnet to the relevant server so there is connectivity but further than that, I have no idea.

Any clues as to what might be causing this?

All help appreciated.

Rory

An LDAP object doesn't try to connect when it's created, so don't be surprised that succeeded. When you say you can telnet, was that to the standard port 23 or did you test 389.

Mack Earnhardt wrote:

An LDAP object doesn't try to connect when it's created, so don't be surprised that succeeded. When you say you can telnet, was that to the standard port 23 or did you test 389.

<snip> Hi

It was port 389. I also, at the suggestion of one of my colleagues, tried setting up Thunderbird to use the LDAP server for an address book. This worked perfectly, so, in terms of connectivity it seems to be working.

Does Rails store any debugging/error info that could help pinpoint a reason for this lack of connectivity?

Regards

Rory

Craig White wrote: <snip>

---- here's how I do it using ruby-ldap

** my_ldap.rb ** require "ldap" # Provides access to authenticate user from LDAP using the user provided user name and password class MyLDAP < LDAP::Conn   BASE_DN = "dc=example,dc=com"   PEOPLE_DN = "ou=people,dc=example,dc=com"   LDAP_HOST = "server.example.com"   LDAP_PORT = 389   PROTOCOL_VERSION = 3   # sets up connection to LDAP server   def initialize (host = LDAP_HOST, version = PROTOCOL_VERSION)     super( host, LDAP_PORT )     set_option( LDAP::LDAP_OPT_PROTOCOL_VERSION, version )     return self   end   # Bind with the user supplied information   def bind(mydn, pass)     dn = "uid=" + mydn + "," + PEOPLE_DN     super( dn, pass )   end end

<snip>

Hi Craig

I will give this a try. Can you perhaps tell me why you use "super" in the method definitions?

Rory

Craig White wrote: <snip> > ---- > here's how I do it using ruby-ldap > > ** my_ldap.rb ** > require "ldap" > # Provides access to authenticate user from LDAP using the user provided > user name and password > class MyLDAP < LDAP::Conn > BASE_DN = "dc=example,dc=com" > PEOPLE_DN = "ou=people,dc=example,dc=com" > LDAP_HOST = "server.example.com" > LDAP_PORT = 389 > PROTOCOL_VERSION = 3 > # sets up connection to LDAP server > def initialize (host = LDAP_HOST, version = PROTOCOL_VERSION) > super( host, LDAP_PORT ) > set_option( LDAP::LDAP_OPT_PROTOCOL_VERSION, version ) > return self > end > # Bind with the user supplied information > def bind(mydn, pass) > dn = "uid=" + mydn + "," + PEOPLE_DN > super( dn, pass ) > end > end <snip>

Hi Craig

I will give this a try. Can you perhaps tell me why you use "super" in the method definitions?

> Craig White wrote: > <snip> > > ---- > > here's how I do it using ruby-ldap > > > > ** my_ldap.rb ** > > require "ldap" > > # Provides access to authenticate user from LDAP using the user provided > > user name and password > > class MyLDAP < LDAP::Conn > > BASE_DN = "dc=example,dc=com" > > PEOPLE_DN = "ou=people,dc=example,dc=com" > > LDAP_HOST = "server.example.com" > > LDAP_PORT = 389 > > PROTOCOL_VERSION = 3 > > # sets up connection to LDAP server > > def initialize (host = LDAP_HOST, version = PROTOCOL_VERSION) > > super( host, LDAP_PORT ) > > set_option( LDAP::LDAP_OPT_PROTOCOL_VERSION, version ) > > return self > > end > > # Bind with the user supplied information > > def bind(mydn, pass) > > dn = "uid=" + mydn + "," + PEOPLE_DN > > super( dn, pass ) > > end > > end > <snip> > > Hi Craig > > I will give this a try. Can you perhaps tell me why you use "super" in > the method definitions? ---- It was years ago when I wrote this and I think I got it off the wiki (http://wiki.rubyonrails.org) - I honestly don't remember but it worked really nicely.