LDAP can be used within Rails by leveraging the Ruby/LDAP module located at http://ruby-ldap.sourceforge.net.
Example
require "ldap"
LDAP::Conn.new("ldap.mycompany.com", 389).bind { |conn|
begin
conn.search("ou=MyOrgUnit, o=MyOrg",
LDAP::LDAP_SCOPE_SUBTREE,
"(cn=Joe Shmo)") { |record|
#do whatever with the record matched, here I just print it out
p record.vals("cn")
}
rescue LDAP::ResultError => msg
$stderr.print(msg)
end
}
Documentation can be found at http://ruby-ldap.sourceforge.net/rdoc
LDAP can be used within Rails by leveraging the Ruby/LDAP module located at http://ruby-ldap.sourceforge.net.
Example
require "ldap"
LDAP::Conn.new("ldap.mycompany.com", 389).bind { |conn|
begin
conn.search("ou=MyOrgUnit, o=MyOrg",
LDAP::LDAP_SCOPE_SUBTREE,
"(cn=Joe Shmo)") { |record|
#do whatever with the record matched, here I just print it out
p record.vals("cn")
}
rescue LDAP::ResultError => msg
$stderr.print(msg)
end
}
Documentation can be found at http://ruby-ldap.sourceforge.net/rdoc