Войдите в ldap с правами администратора и выполните поиск пользователя по электронной почте и паролю с фильтром:
require 'rubygems'
require 'net/ldap'
ldap = Net::LDAP.new :host => server_ip_address,
:port => 389,
:auth => {
:method => :simple,
:username => "cn=manager,dc=example,dc=com",
:password => "opensesame"
}
filter = Net::LDAP::Filter.eq( "email", "joe@email.com" )
treebase = "ou=Users,dc=example,dc=com"
@auth = false
ldap.search( :base => treebase, :filter => filter ) do |entry|
ldap2 = Net::LDAP.new :host => server_ip_address,
:port => 389,
:auth => {
:method => :simple,
:username => entry.dn,
:password => "joe's password"
}
@auth = true if ldap2.bind
end
puts "user authenticated" if @auth