I’m working on a project that uses Ruby, Rails (RoR), and LDAP authentication.
I searched the net for a long time, but finally got something to work for me.
… just use your own username, password & hostname.
Note that CORP is my domain name. Also note that the username and password should be contained in SINGLE QUOTES unless you have some reason to use double quotes…. that messed me up for a while.
<pre>
require ‘rubygems’
require ‘net/ldap’
user = ‘CORP\my_username’
pass = ‘my_password’
ldap = Net::LDAP.new :host => “x.x.x.x”, :port => 389, :auth => {:method => :simple, :username => user, :password => pass}
p (ldap.bind) ? “Authorization Succeeded!” : “Authorization Failed: #{ldap.get_operation_result.message}”
</pre>